Skip to content

Regression when spreading Types in an Alias: TS1265: A rest element cannot follow another rest element.Β #57828

Closed as not planned
@pfeileon

Description

@pfeileon

πŸ”Ž Search Terms

TS1265

πŸ•— Version & Regression Information

  • This changed between versions 5.3.3 and 5.4.2

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.4.2#code/MYewdgzgLgBAZgSwE7QPICMBWBTYsC8MA3nCCAFwwDkpIVAvjAIYQyiRQDcAUO9DBFzgAJhhx4YhIuiZJKVGUgbNWfLt17h+iFFADCWqEzAEYAbSpMANlaoAaGADpnACjG4ojgNbYAnhBcdNCwPAEpQgF0VNkMeNQEhMGEDDmNTC2tbB2dHNxC8bz8AwXZRfKhwqJYYjh5uKF8AB2wYADFkaAAVJpbCBuaQOHgO-UM0nn6WgGVE4W7myRhJwYTSlOhxjUmYAwBbdAQwbDmexaRsJmFwK19zbhgnZ3bdeew7e8fHGdLX94ieIA

πŸ’» Code

const firstObject = {foo: 'foo'} as const;
const secondObject = {bar: 'bar'} as const;

const firstConstant = ['all', ...(Object.keys(firstObject))] as const;
const secondConstant = ['all', ...(Object.keys(secondObject))] as const;

type FirstType = typeof firstConstant;
type SecondType = typeof secondConstant;

type CombinedType = readonly [
  ...FirstType,
  ...SecondType,
];

Workbench Repro

πŸ™ Actual behavior

A rest element cannot follow another rest element.(1265)

πŸ™‚ Expected behavior

No error

Additional information about the issue

No response

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