-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Constrained types is not assignable to constrainer union types, and failed to narrow its type #8563
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
Hmm. This one is tricky. Currently the only type we consider assignable to a type parameter is that same type parameter (and |
Yeah, it did basically what @ahejlsberg said -- but (1) only locally, when getting the narrowed type, and (2) not updated for control-flow rewrite of narrowing. So it can't be used as-is. |
I don't think the solution in #7422 works. The thing that makes this issue complicated is that you can't just clone type parameters without also being prepared to treat the clones as aliases for the original type parameter in the type instantiation logic. Otherwise you'll "leak" type parameters. |
This has worked correctly for a while now. The type guard produces type |
TypeScript Version:
master
Code
Expected behavior:
Actual behavior:
The text was updated successfully, but these errors were encountered: