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

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

Closed
pfeileon opened this issue Mar 18, 2024 · 4 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@pfeileon
Copy link

πŸ”Ž 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

@Andarist
Copy link
Contributor

This is working as intended now and was changed here, see the discussion before this comment

@pfeileon
Copy link
Author

This is working as intended now and was changed here, see the discussion before this comment

Is it? In my example it's all strings, the tuples aren't of mixed types.

@Andarist
Copy link
Contributor

It doesn't matter what are the types contained in those arrays. The reported error is pretty generic and is only concerned with the fact that you are using multiple rest elements:

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

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Mar 19, 2024
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants