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

Spreading one named tuple in another throws an error #43516

Closed
pushkine opened this issue Apr 3, 2021 · 1 comment
Closed

Spreading one named tuple in another throws an error #43516

pushkine opened this issue Apr 3, 2021 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@pushkine
Copy link
Contributor

pushkine commented Apr 3, 2021

TS stable and nightly
Playground Link

type T0 = [...[bar: string]] // = [bar: string]
type T1 = [foo: string, ...[bar: string]] // Error : Tuple members must all have names or all not have names. (5084)
@andrewbranch andrewbranch added the Bug A bug in TypeScript label Apr 5, 2021
@andrewbranch andrewbranch added this to the TypeScript 4.3.1 milestone Apr 5, 2021
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Apr 7, 2021
@armanio123
Copy link
Member

This is by design. Is a bit confusing but what's happening is that type T1 = [foo: string, ...[bar: string]] is an invalid syntax. Instead can label it and fix it by changing it as:

type T1 = [foo: string, ...args: [bar: string]]

There has been a design discussion some time ago about this. You can check more details here: #43744

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants