Skip to content

Variadic with "named tuples" doesn't preserve name #39941

Closed
@ChuckJonas

Description

@ChuckJonas

Not sure this actually should be possible... I guess it would get funky as typescript would have to deal with naming conflicts.

TypeScript Version: 4.1.0-dev

Search Terms:
Variadic, Named Tuples
Code

type Append<I, T extends unknown[]> = [...T, last:I];
type FooBar = Append<string, [foo: number, bar: boolean]>

Expected behavior:
Should preserve named tuples labels:

type FooBar = [foo: number, bar: boolean, last: string]

Actual behavior:

type FooBar = [number, boolean, string]

Playground Link:
https://www.typescriptlang.org/play?ts=4.0.0-beta#code/C4TwDgpgBAgmkDsAmAeAkgGigFShAHsBMgM5QCuCA1ggPYDuCA2gLoB8UAvFEwHT-YsAGwCGJYAC40LANwAoUJCgAxWrQBCIgE5dY8YqnFaAlggDmWJgDM1EqAnIBbAEYQtWZ9rvO1QiCIR2OSA

Related Issues:
none

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions