-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Change in inferred type in 3.6 for function call using generic union instantiated at string literal #33227
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
Comments
I think this probably has to do with #33131 (comment) and is therefore a bug. The example above was a generic function with its argument typed as |
Yeah, I think it's to do with the changes to naked type parameter inference. @weswigham mind taking a look to confirm before I close this as a duplicate? |
@lukehoban Here's a link to a build you can try to see if it fixes the problem: |
(Hi Luke! 👋) This is an effect of #32460, and I would argue one that is intended. In the call to The string literal const y = ifUndefined(new Promise<NetworkProtocol>(() => {}), "TCP" as const); |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
1 similar comment
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
TypeScript Version: 3.6.2
Search Terms: regression, string literal, union, 3.6, inference, generic.
Code
Expected behavior:
No error (3.5 and earlier).
Actual behavior:
A type error (3.6.2):
Playground Link: Playground. The TypeScript Playground doesn't appear to yet use 3.6.2 though so this doesn't repro in the playground.
Note that this example does work as expected - and looks morally "the same":
The text was updated successfully, but these errors were encountered: