Skip to content

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

Merged

Conversation

weswigham
Copy link
Member

Fixes #25971

!!! 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"]'.
Copy link
Member

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

Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

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.

@weswigham weswigham merged commit d7390c0 into microsoft:master Nov 6, 2018
@weswigham weswigham deleted the elaborate-avoid-generic-indexes branch November 6, 2018 20:51
ghost pushed a commit that referenced this pull request Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants