You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeGetTupleKeys<Tupleextendsunknown[]>={[KinkeyofTuple]: K}[keyofTuple];// In 5.4.2 we get `number | "0"`// In 5.3.3 we get `number | "0" | "1"`{typetest=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`{typetest=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"
π Search Terms
"tuple", "tuple type"
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.4.2#code/C4TwDgpgBA4hwBUCuYA2EDSEQGcA8ya0EAHsBAHYAmOUSFA1hQPYDuFA2gLoB8UAvFADeHDFACWFKA2zMAZlELouALigYAvhxkh5ilMoDcAKGMB6M1ACSUgKwA6ACz2ATFFbQA5vCgADCkgAtgBGEABOUAA+UABEAAwxvuaWNlAOAMz26e5ePv5BoRHR8TFRsQCMicZCoJBQ5DjAArDwSpjY+ByNYZKeADRQ9kMBIeHcvBrJUNNQAHoA-KYW1nZOrjlQ3k2+JWVuxZW+UAAUrAAW4gDGZxK0EACOSOIAbgCG6BRNrxQgrK+4AEopqkMlkNls-LsDqVoi4kjVwNAGk1BHBEAZ2rg8F1gD0KP0oCNChMpjMFsYgA
π» Code
π 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 keysnumber | "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
The text was updated successfully, but these errors were encountered: