-
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
Variadic tuple types #39094
Merged
Merged
Variadic tuple types #39094
Changes from 30 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
7410ac9
Initial implementation of variadic tuple types
ahejlsberg e5d6be7
Accept new baselines
ahejlsberg 6d6bf6d
Handle variadic elements in tuple type inference
ahejlsberg 5679f36
Special case inference between tuples with matching structure
ahejlsberg 94dd625
Restore check that rest element is last element
ahejlsberg 8669342
Handle variadic tuples in relationship checking
ahejlsberg 34fd780
Accept new baselines
ahejlsberg e8466d7
Infer readonly constraints when inferring from readonly tuples
ahejlsberg 20eb59e
Fix lint issues
ahejlsberg 54d7d40
T assignable to readonly [...T] and [...T] assignable to T
ahejlsberg d2b3128
Consistent tuple normalization
ahejlsberg 5902c21
Create variadic tuple types from array literal expressions
ahejlsberg 5d78ed1
Accept new baselines
ahejlsberg b6b9d4a
Array literals have tuple types when contextual type is readonly
ahejlsberg 0a7c6a9
Accept new baselines
ahejlsberg 97184ab
Optional elements before required elements become required elements
ahejlsberg 7449a6b
Update logic for rest parameters and spread arguments
ahejlsberg 7f0917b
Revert special case of contextual readonly array type
ahejlsberg 0388e8e
Accept new baselines
ahejlsberg 635d440
Fix lint issue
ahejlsberg 32bbd4c
Switch entirely to createTupleType based on element flags
ahejlsberg 10a9eb9
Don't infer readonly tuple types when inferring to variadic elements
ahejlsberg bb989fc
Handle mapped types applied to generic tuple types
ahejlsberg fec03a1
Handle constraint of indexed access type with generic tuple type
ahejlsberg 9a04edc
Merge branch 'master' into variadicTuples
ahejlsberg 01d3b54
Accept new baselines
ahejlsberg 2791938
Address CR feedback
ahejlsberg d37c514
Merge branch 'master' into variadicTuples
ahejlsberg 7593522
Simplify indexed access types involving generic tuple types
ahejlsberg eb50893
Propagate checkMode into getSpreadArgumentType
ahejlsberg 8f41104
Guard against missing globalArrayType
ahejlsberg eedf7f1
Inference to [...T, ...U] based on implied arity of T
ahejlsberg bc04a8d
Merge branch 'master' into variadicTuples
ahejlsberg aa2c49d
Accept new baselines
ahejlsberg 7bc595b
Add tests
ahejlsberg 0fc28f2
Emit .d.ts from tests
ahejlsberg 11f70be
Address CR feedback
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
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
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.
Why are
Required
andOptional
both flags? This means we can mistakenly mark a member as both required and optional, which seems incorrect. Actually, I'm pretty sure all of these are mutually exclusive - is there a good reason this shouldn't beElementKind
instead ofElementFlags
?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.
It's similar to
TypeFlags
and others. Makes it cheaper to check for multiple values at once.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.
But the most we use at once is two... Is it really worth giving up exhaustiveness and exclusivity checking to replace so few expressions?
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.
Yes, I think this is fine, particularly as the current scheme makes it easy for us to add additional element flags that are orthogonal to the kind of element.