Bug Report
🔎 Search Terms
const array tuple parameter spread
🕗 Version & Regression Information
- This is the behavior in every version I tried,.
⏯ Playground Link
Playground Link
💻 Code
declarefunctioneach<TextendsReadonlyArray<any>>(cases: ReadonlyArray<T>): (fn: (...args: T)=>any)=>void;constcases=[[1,'1'],[2,'2'],]asconst;consteacher=each(cases);// Error.eacher((a,b)=>{});// No error?eacher((...args)=>{const[a,b]=args;});🙁 Actual behavior
Argument of type '(a: 1 | 2, b: "1" | "2") => void' is not assignable to parameter of type '(...args: readonly [1, "1"] | readonly [2, "2"]) => any'.
Types of parameters 'a' and 'args' are incompatible.
Type 'readonly [1, "1"] | readonly [2, "2"]' is not assignable to type '[a: 1 | 2, b: "1" | "2"]'.
The type 'readonly [1, "1"]' is 'readonly' and cannot be assigned to the mutable type '[a: 1 | 2, b: "1" | "2"]'.(2345)
Obviously they're not assignable, but why did we come up with [a: 1 | 2, b: "1" | "2"] and not readonly [a: 1 | 2, b: "1" | "2"]?
🙂 Expected behavior
No error, as though it had been expanded separately.
See also: DefinitelyTyped/DefinitelyTyped#64739
Bug Report
🔎 Search Terms
const array tuple parameter spread
🕗 Version & Regression Information
⏯ Playground Link
Playground Link
💻 Code
🙁 Actual behavior
Obviously they're not assignable, but why did we come up with
[a: 1 | 2, b: "1" | "2"]and notreadonly [a: 1 | 2, b: "1" | "2"]?🙂 Expected behavior
No error, as though it had been expanded separately.
See also: DefinitelyTyped/DefinitelyTyped#64739