-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Mapped types #12114
Merged
+2,757
−171
Merged
Mapped types #12114
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
7cd39e3
Parsing of mapped types
ahejlsberg d1a8af5
Parse '[P in K]' part of mapped type as a type parameter declaration
ahejlsberg fc450a2
Introduce MappedType in type checker
ahejlsberg ecdb74c
Merge branch 'master' into mappedTypes
ahejlsberg 7807ac9
Attach symbols to mapped types
ahejlsberg 1c7b397
Introduce instantiateCached function
ahejlsberg 507ab30
Handle readonly and optional properties + index signatures
ahejlsberg 2564e1c
Handle recursion in mapped type display
ahejlsberg 5de63a7
Validate constraint type in mapped type
ahejlsberg de93876
Correct symbol display for type parameter of mapped type
ahejlsberg 9f3aa38
Improve sharing by re-instantiating top level type aliases
ahejlsberg 8aef1e6
Type inference for mapped types
ahejlsberg 7ca5923
Merge branch 'master' into mappedTypes
ahejlsberg a562d6e
Make keyof T assignable to and subtype of string | number
ahejlsberg cf2953b
Add relations for keyof S / keyof T and [P in S]: X / [P in T]: X
ahejlsberg aca7e2f
Don't include private/protected properties in keyof T
ahejlsberg 3dd11e4
Properly implement type relationship for '[P in S]: X' and '[P in T]: Y'
ahejlsberg 2170ff6
Defer resolution of mapped types to enable recursive definitions
ahejlsberg b81c226
Use pull model to obtain type alias information for type nodes
ahejlsberg de2da2c
Accept new baselines
ahejlsberg aca1ab3
Check mapped type constraint is assignable to string | number
ahejlsberg 64d2698
Merge branch 'master' into mappedTypes
ahejlsberg cd185f2
Add declaration emit support
ahejlsberg 1c7ec6b
Add missing node visits in forEachChild
ahejlsberg 364142c
Improve type inference for types with same generic type alias
ahejlsberg e9b6ddc
Add tests
ahejlsberg ca3f797
More tests
ahejlsberg 5028a44
Accept new baselines
ahejlsberg 9ac7667
Address CR feedback
ahejlsberg 6ceab7b
Accept new baselines
ahejlsberg cd05c07
Add comment explaining type alias instantiation strategy
ahejlsberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
MappedType seems to behave like a TypeLiteral elsewhere, but I'm not why it has
HasLocals
here like TypeAliasDeclaration does. Is it that MappedType introduces a new name for the parameter type?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.
This is because of the type parameter introduced by
[P in ...]
. We want that symbol entered into thelocals
symbol table such that it is accessible within the mapped type, but not from the outside (unlike members).