-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Avoid elaborating on generic indexes #28294
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
Avoid elaborating on generic indexes #28294
Conversation
!!! error TS2345: Type 'T' is not assignable to type 'S["a"] & T'. | ||
!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"] & T'. | ||
!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"]'. | ||
!!! error TS2345: Type 'T' is not assignable to type 'S["a"]'. |
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.
Seems a little weird to have this extra line, and it's supposedly because intersections always have an extra this
-type? Seems like a leak of impl. details
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.
Should open another issue for this; this was the prior message.
const targetPropType = getIndexedAccessType(target, nameType, /*accessNode*/ undefined, errorType); | ||
if (targetPropType === errorType || targetPropType.flags & TypeFlags.IndexedAccess) continue; // Don't elaborate on indexes on generic variables |
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.
Why do you have to look at the errorType
?
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.
errorType
is what getIndexedAccessType
returns when the property doesn't exist; ergo we do not want to dive into it. I just moved up the check from a line or two below.
Fixes #25971