-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
expectType
generic causes incorrect inference
#142
Comments
I have this issue too |
Added a test. @sindresorhus do you have any idea how to go about fixing this? From the conversation in |
No |
Can you submit it it (commented out)? |
By submit it do you mean as a PR? |
Yes |
See #196 for discussion on this. |
Given how TypeScript and generics work, I think currently the only way of solving this is by storing the result of the declare const inferrable: <T = 'SomeDefaultValue'>() => T
const val = inferrable();
expectType<number>(val); TypeScript forces the generic to fit in the argument. And there doesn't seem to be a way to prevent this. It would be fixed by something like |
expectType
doesn't work properly with generic functions. Here's a repro:I'm not sure if it's possible to fix given the API design, but here's the same test using expect-type which fails as it should.
The text was updated successfully, but these errors were encountered: