-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
I tested my issue with this PR, but it doesn't fix it. |
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}`]'. |
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 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}`]'
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.
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.
Fixes #47794.