Exclude mapped types with 'as' clauses from certain checks - #47889
Merged
Conversation
|
I tested my issue with this PR, but it doesn't fix it. |
Anders Hejlsberg (ahejlsberg)
requested a review
from Ryan Cavanaugh (RyanCavanaugh)
February 19, 2022 18:14
Nathan Shively-Sanders (sandersn)
requested a review
from Gabriela Araujo Britto (gabritto)
February 24, 2022 17:24
| 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.
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}`]'
Member
Author
There was a problem hiding this comment.
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.
Gabriela Araujo Britto (gabritto)
approved these changes
Feb 24, 2022
Raghav Thind (raghavthind2005)
approved these changes
Mar 15, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #47794.