-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Show an elaboration when accessing a non-existent property of a union type #10582
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Fixes microsoft#10256. Accessing a non-existant property on union types should now show an elaboration in the error message specifying the first constituent type that lacks the property.
Hi @oijazsh, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
!!! error TS2339: Property 'toBAZ' does not exist on type 'boolean'. | ||
!!! error TS2339: Property 'toBAZ' does not exist on type 'true'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird - let's exclude TypeFlags.Boolean
along with TypeFlags.Enum
on line 10814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eugh.
How about for enums and booleans we don't dive in? Specifically, you can check TypeFlags.Boolean
and TypeFlags.Enum
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great minds think and read GitHub on Sunday nights alike
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, TypeFlags.Primitive
is probably fine to check too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow GitHub syncs weird-like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Primitive
is probably correct. Let's have a test for
declare const x: "foo" | "bar";
x.nope();
Looks pretty good to me after a couple minor fixes. @mhegazy thoughts on letting this into |
Fixed the typo and excluded unions that are also |
sorry for the delay. loos good. |
This fixes issue #10256 by showing an elaboration when accessing a non-existant property of a union type. It does not show an elaboration in the following cases:
(It probably should in the second case, but that hasn't been discussed)