For the GetLength type, you can actually just access the length property via bracket notation and receive the same result:
typeGetLength<Textendsunknown[]>=T["length"];
I would recommend this method more because it looks like it's intrinsic behavior built within TypeScript to set that and I would assume it would also be faster and result in less type computations. Finally, it would also get rid of the never fail-safe in the original GetLength type.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For the
GetLength
type, you can actually just access thelength
property via bracket notation and receive the same result:I would recommend this method more because it looks like it's intrinsic behavior built within TypeScript to set that and I would assume it would also be faster and result in less type computations. Finally, it would also get rid of the
never
fail-safe in the originalGetLength
type.