Type issue with `1.115` upgrade
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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