Skip to content
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

Merged
merged 7 commits into from
Sep 8, 2020

Conversation

ahejlsberg
Copy link
Member

Fixes #40235.

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Aug 25, 2020
@ahejlsberg
Copy link
Member Author

@typescript-bot test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 25, 2020

Heya @ahejlsberg, I've started to run the extended test suite on this PR at 355706d. You can monitor the build here.

@ahejlsberg
Copy link
Member Author

Although unrelated to PR, checking to see if stricter circular recursion check in type inference can fix RWC OOM.

@ahejlsberg
Copy link
Member Author

@typescript-bot test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 25, 2020

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];
Copy link

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahejlsberg ahejlsberg merged commit cea1cfb into master Sep 8, 2020
@ahejlsberg ahejlsberg deleted the fix40235 branch September 8, 2020 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

unbounded type is not strict
4 participants