-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Conditional type produced different behavior when used in generic type #55610
Comments
Yes it is the same issue. But this case is even harder to reason because when it is not a generic type, it is evaluated as an empty set, but with generic type, it is evaluated as an empty union. |
You're overthinking it-- |
When it's a generic type it's evaluated distributive, when it's not a generic type it's not. |
Yes, maybe. What I'm really dealing with is defining types with straight forward behavior over the special types: For example: type Merge<A extends Record<any, any>, B extends Record<any, any>> = ...
Merge<{ a: 1 }, any>
Merge<{ a: 1 }, never> // this is allowed due to the issue here, I think I found myself needs to add special handling for |
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
π Search Terms
conditional type, generic type, behavior
π Version & Regression Information
tested on 5.2.2
β― Playground Link
https://www.typescriptlang.org/play?#code/C4TwDgpgBAGlC8UB2EBuEBOUIA9gSQBMBnKAewCMArCAY2CgH4pgMBXaALigDMBDADbEIAKBGhIUAEoAeACoA+BFDnY8BEuWp0GzVhyjd+Q0ePDQAmstkp0GBSKA
π» Code
π Actual behavior
π Expected behavior
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: