Skip to content

Exclude mapped types with 'as' clauses from certain checks #47889

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
merged 3 commits into from
Mar 16, 2022
Merged

Conversation

ahejlsberg
Copy link
Member

Fixes #47794.

@j3k0
Copy link

j3k0 commented Feb 17, 2022

I tested my issue with this PR, but it doesn't fix it.

@ahejlsberg ahejlsberg added this to the TypeScript 4.7.0 milestone Feb 19, 2022
@sandersn sandersn requested a review from gabritto February 24, 2022 17:24
@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Backlog Bug PRs that fix a backlog bug labels Feb 24, 2022
const get = <T extends string>(t: T, foo: Foo<T>): T => foo[`get${t}`]; // Type 'Foo<T>[`get${T}`]' is not assignable to type 'T'
~~~~~~~~~~~~~~
!!! error TS2322: Type 'Foo<T>[`get${T}`]' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo<T>[`get${T}`]'.
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 we get this error elaboration here? I find it confusing to state that 'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo<T>[`get${T}`]'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I never find that error elaboration useful, and we include it every time an assignment to a type parameter fails. I think we should get rid of it, but that would be another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Incorrect substitution on index access with generic key type on generic mapped type with key remapping
5 participants