MetaMask / MetaMask/metamask-onboarding
Bug in costructor typing
- Dominant language
- TypeScript
- Stars
- 150
- Forks
- 55
- PR merge metrics
- No merged PRs in 30d
Description
```
new MetaMaskOnboarding({
forwarderOrigin: 'http://localhost:3000',
forwarderMode : 'OPEN_TAB'
})
```
throws : `Type '"OPEN_TAB"' is not assignable to type '"INJECT"'.ts(2322)`
Which is consequnce of bad typing of constructor.
Guess you wanted to have something like
```
export default class Onboarding {
static FORWARDER_MODE = {
INJECT: 'INJECT' as const,
OPEN_TAB: 'OPEN_TAB' as const,
};
constructor({
forwarderOrigin = 'https://fwd.metamask.io',
forwarderMode = Onboarding.FORWARDER_MODE.INJECT,
} : {
forwarderMode? : keyof typeof Onboarding.FORWARDER_MODE,
forwarderOrigin? : string
}) {
}
}```
which provides defaults but same time gives proper types for constructor. Should i open PR?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the TypeScript Onboarding constructor and its FORWARDER_MODE definition, as shown in the issue. Reproduce the reported OPEN_TAB type error, then verify that both forwarder modes are accepted while the defaults remain available and the constructor type-checks successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100