-
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
Consistently error when rest element isn't last in tuple type #40254
Conversation
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 355706d. You can monitor the build here. |
Although unrelated to PR, checking to see if stricter circular recursion check in type inference can fix RWC OOM. |
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 80e6df6. You can monitor the build here. |
type U2 = [...[string, ...Numbers], boolean]; | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS1256: A rest element must be last in a tuple type. | ||
type U3 = [...[string, number], boolean]; |
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.
Not sure if I get this right, does this mean we still have (or bring back) the constraint that a rest element must be at last in a tuple?
In 4.0 doc, I can see the below update:
The second change is that rest elements can occur anywhere in a tuple - not just at the end!
Previously, TypeScript would issue an error like the following:
But with TypeScript 4.0, this restriction is relaxed.
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.
Fixes #40235.