-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[ListItem] Add type test for button prop #15049
[ListItem] Add type test for button prop #15049
Conversation
No bundle size changes comparing ae31efe...93fc476 |
Yeah, this is pretty unfortunate. Looks like it's an edge case which only comes up when a record type has a single property, and they consider it working as intended, per this comment. I wonder if we can add another overload to handle the general boolean case or if that destroys all our hard-earned type safety? |
I think we're back at the start by that point. With the general boolean case we would need to infer the At least we have documented the issue. Maybe we can improve it later. |
Is this issue reported in Typescript repository ? |
@VincentLanglet It looks like it. It essentially comes down to |
Why not just do <ListItem button={(someBoolean == someOtherBoolean) as false} :-D |
Since #13868
button
is a discriminant for the props ofListItem
. This means it can't be assignedboolean
. Eitherfalse
ortrue
has to be used.You can't pass the union of the possible types of discriminants in TypeScript. A simplified illustration of this problem:
Might be a limitation of TypeScript, might a bug.
/cc @pelotom