-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump typescript
from ~5.0.4
to ~5.1.6
#4576
Conversation
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/typescript@5.0.4 |
typescript
from ~5.0.4
to ~5.1.6
400fcca
to
703d3c4
Compare
const implementation = this.implementations[type].method as ( | ||
...args: Parameters<RateLimitedApis[ApiType]['method']> | ||
) => ReturnType<RateLimitedApis[ApiType]['method']>; | ||
|
||
if (!implementation) { | ||
throw new Error('Invalid api type'); | ||
} | ||
|
||
return implementation(...args) as ReturnType< | ||
RateLimitedApis[ApiType]['method'] | ||
>; | ||
return implementation(...args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MetaMask/snaps-devs This change fixes the following regression:
ERROR: src/RateLimitController.ts:173:27 - error TS2345: Argument of type 'Parameters<RateLimitedApis[ApiType]["method"]>' is not assignable to parameter of type 'never'.
Type 'unknown[]' is not assignable to type 'never'.
Type 'Parameters<RateLimitedApis[keyof RateLimitedApis]["method"]>' is not assignable to type 'never'.
Type 'unknown[]' is not assignable to type 'never'.
Type 'Parameters<RateLimitedApis[string | number | symbol]["method"]>' is not assignable to type 'never'.
Type 'unknown[]' is not assignable to type 'never'.
Type 'Parameters<RateLimitedApis[string]["method"]> | Parameters<RateLimitedApis[number]["method"]> | Parameters<RateLimitedApis[symbol]["method"]>' is not assignable to type 'never'.
Type 'Parameters<RateLimitedApis[string]["method"]>' is not assignable to type 'never'.
Type 'unknown[]' is not assignable to type 'never'.
Type 'never[]' is not assignable to type 'never'.
173 return implementation(...args) as ReturnType<
Both before and after the change, the as assertion narrows the type of implementation
, which is currently typed to the universal supertype (i.e. type constraint) of all RateLimitedApi
method
types (i.e. ActionConstraint
) because there's no ApiType
information to narrow it.
The only difference is that the type assertion now narrows the parameters (...args
) of implementation
, in addition to its return type.
References
Changelog
Checklist