GeezerVison is showing github.com — Higher order type relations for mapped types by ahejlsberg · Pull Request #12351 · microsoft/TypeScript
Conversation
This PR adds a number of type relations for higher order mapped types and indexed access types (i.e. un-instantiated generic forms of the types).
- A type
S[K] is related to a type T[K] if S is related to T.
- A type
T is related to a type { [P in keyof T]: X } if T[P] is related to X.
- A type
{ [P in keyof T]: X } is related to a type T if X is related to T[P].
The PR furthermore adds the following rules:
- The operation
keyof { [P in K]: X } is equivalent to just K. For example, keyof Partial<T> is equivalent to keyof T.
- The operation
{ [P in K]: T}[X] is equivalent to an instantiation of T where X is substituted for every occurrence of P. For example, { [P in K]: Box<T[P]> }[X] is equivalent to Box<T[X]>.
- In
type T = { [P in K]: X } it is an error for K to directly or indirectly reference T.
- Given a type parameter
T with a constraint that includes a string index signature of type X, the apparent type of an indexed access type T[K] is X.
Fixes #12311.
Fixes #12315.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
alitaheri reacted with heart emoji
This was referenced Jul 17, 2017
Reviewers
1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.