Closed as not planned
Description
π Search Terms
"tuple", "tuple type"
π Version & Regression Information
- This changed between versions 5.3.3 and 5.4.2
β― Playground Link
π» Code
type GetTupleKeys<Tuple extends unknown[]> = {[K in keyof Tuple]: K}[keyof Tuple];
// In 5.4.2 we get `number | "0"`
// In 5.3.3 we get `number | "0" | "1"`
{type test = GetTupleKeys<[string, ...number[]]>}
// ^?
// In 5.4.2 we get `"0" | 2 | "1"` (which is equivalent anyways)
// In 5.3.3 we get `"0" | "1" | 2`
{type test = GetTupleKeys<[string, number]>}
// ^?
π Actual behavior
In 5.4.2, rest arguments in tuples no longer get a dedicated key/index when mapping the tuple type. In the above example, the tuple type [string, ...number[]]
effectively produces the keys number | "0"
π Expected behavior
No regression. The above example should be as 5.3.3 and resolve to the keys number | "0" | "1"
Additional information about the issue
This is specifically impacting the following code:
https://github.com/sindresorhus/type-fest/blob/main/source/set-parameter-type.d.ts#L7
As reported in:
sindresorhus/type-fest#831