UI5 / UI5/typescript

Type issue with `1.115` upgrade

Open
#416 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
213
Forks
35
Avg merge
37m
Merged PRs (30d)
1

Description

Following type upgrade, now code has to look like this:
let a = MessageBox.Action.ABORT;

However when having to type out an argument of a callback function with the possible Actions, I find myself having to do this:

                    myCallback(
                        action: (typeof MessageBox.Action)[keyof typeof MessageBox.Action],
                    ) => {
                        if (action === MessageBox.Action.OK) {
                            allGood()
                        } else {
                            badStuff();
                        }
                    }

which is quite cumbersome. The natural approach of typing action as MessageBox.Action does not seem to work, I get

Cannot access 'MessageBox.Action' because 'MessageBox' is a type, but not a namespace. Did you mean to retrieve the type of the property 'Action' in 'MessageBox' with 'MessageBox["Action"]'

Am I missing something?

Many thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the callback-parameter error shown for MessageBox.Action after the 1.115 type upgrade, then inspect the relevant type declarations to determine how Action is exposed. Done means the supported way to type a callback argument is documented or the type issue is corrected, with the example compiling.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.