-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TSX type inference is broken when using intersection types #21632
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
@weswigham thoughts on this? |
I think the jsx inference/contextual typing PR I currently have open is mostly to fix exactly this, since I discovered the same issue when looking at changing formik. |
Also, hold on: those 2.6.2 errors are themselves erroneous. Setting a default doesn't constrain the type variable - literally any props should be be OK to pass for that component - we just messed up before and instantiated with the default like it was the constraint before. |
This was my interpretation as well. Seems useless to have a generic component if you're not allowed to infer a type from its props. |
@weswigham, so the actual behavior in 2.7.1 is correct and it will stay like this after your PR will be merged? |
Yeah. You should be using |
OK, thanks for clarification. |
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 2.7.1, 2.8.0-dev.20180204
Search Terms: jsx tsx intersection
Code
Expected behavior:
Should generate 2 errors as in 2.6.2:
Actual behavior:
No errors are generated
Playground Link: -
Related Issues: maybe related #21427
The text was updated successfully, but these errors were encountered: