Revert "Always substitute indexed generic mapped type when getting constraint from indexed access"#57202
Conversation
…nstraint from indexed access (microsoft#53066)" This reverts commit abb4052.
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
| } | ||
|
|
||
| function getConstraintFromIndexedAccess(type: IndexedAccessType) { | ||
| if (isMappedTypeGenericIndexedAccess(type) || isGenericMappedType(type.objectType)) { |
There was a problem hiding this comment.
while my comment here can be partially true - so far I couldn't find the situation in which this extra check would benefit anything (after adjustments) since getSimplifiedIndexedAccessType already performs this substitution when it's safe to do so
|
|
||
| function genericTest<K extends string>(objectWithUnderscoredKeys: ObjectWithUnderscoredKeys<K>, key: K) { | ||
| const shouldBeTrue: true = objectWithUnderscoredKeys[`_${key}`]; | ||
| const shouldBeTrue: true = objectWithUnderscoredKeys[`_${key}`]; // assignability fails here, but ideally should not |
There was a problem hiding this comment.
Those kinds of cases could always be OK if we could determine that the template type doesn't depend on the original K. I don't think the compiler is equipped to check this sort of thing right now though.
|
@DanielRosenwasser I don't think this revert needs to be cherry-picked or anything, right? Since we'll sync the release branch with |
|
Yeah, it'll be in the RC |
reverts my own #53066 , fixes #53066 (comment)
cc @ahejlsberg @weswigham