Consistently error when rest element isn't last in tuple type#40254
Consistently error when rest element isn't last in tuple type#40254ahejlsberg merged 7 commits intomasterfrom
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.
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.
Fixes #40235.