Open
Description
🔎 Search Terms
"generic", "tuple", "spread", "rest", "ts2556", "a spread argument must either have a tuple type or be passed to a rest parameter"
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about spreading into argument lists
⏯ Playground Link
💻 Code
declare const f: () => void
declare const x: readonly []
f(...x) // works
const test = <T extends readonly []>(x: T) =>
f(...x) // does not work
🙁 Actual behavior
Attempting to spread a generically-typed value whose constraint guarantees tuple-ness into a compatible argument list is forbidden.
🙂 Expected behavior
I should be allowed to do this.
Additional information about the issue
Possibly-related issues:
- When trying to use mapped tuples as rest parameters error 'A rest parameter must be of an array type' given #29919
- Spread operator should not have worse ergonomics than
apply
- unexpected error spreading a union-of-tuples #49802 - Using Parameters in a class member function gets incorrect result while all parameters are optional. #53541