π Search Terms
tuple, variadic element
π Version & Regression Information
Since 4.0.5
β― Playground Link
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABMAPAFUQUwB5U2AEwGdFwBrMOAdzAG0BdAGkQDUtd9jSwLq76AfAApsALloAjOHAA2mAIZhmAOlUsVqtE0Srl8gE4BzIqJYBKRAG8AUIjt39mKCH1JsAbmsBfRNesQEIihEeUQAXmQhWih9EExmACZmACIJZOYYuO0ARhT5ZMQzd0QAehKAUX19OH1mHAAHTGhMAkQEkKMQAFt8KCJmCRBgwzhggGYgA
π» Code
function f<U extends unknown[], V extends unknown[]>(x:[boolean, ...V, ...U], ...args:V) {
return x;
}
const a = f([true, 2, "b", true], 1, "a" ); //Error, expected 2 arguments, but got 3
π Actual behavior
Compiler sees error
π Expected behavior
No error, because as #39094 states
If the middle part of T is exactly two variadic elements ...A and ...B, and an implied arity exists for A, infer from a tuple consisting of the initial middle part of S to A and from a tuple consisting of the remaining middle part of S to B, where the length of the initial middle part corresponds to the implied arity for A.
As I understand the middle part of S is 2, "b", true and in the middle part of T we have ...V, ...U then 2, "b" is ...V and true is ...U.
Additional information about the issue
https://stackoverflow.com/posts/79784883/edit
π Search Terms
tuple, variadic element
π Version & Regression Information
Since 4.0.5
β― Playground Link
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABMAPAFUQUwB5U2AEwGdFwBrMOAdzAG0BdAGkQDUtd9jSwLq76AfAApsALloAjOHAA2mAIZhmAOlUsVqtE0Srl8gE4BzIqJYBKRAG8AUIjt39mKCH1JsAbmsBfRNesQEIihEeUQAXmQhWih9EExmACZmACIJZOYYuO0ARhT5ZMQzd0QAehKAUX19OH1mHAAHTGhMAkQEkKMQAFt8KCJmCRBgwzhggGYgA
π» Code
π Actual behavior
Compiler sees error
π Expected behavior
No error, because as #39094 states
As I understand the middle part of S is
2, "b", trueand in the middle part of T we have ...V, ...U then2, "b"is ...V andtrueis ...U.Additional information about the issue
https://stackoverflow.com/posts/79784883/edit