#Q['length'] extends 4 but number does not extend Q['length']
6 messages · Page 1 of 1 (latest)
because number doesn't extend 4. here's a simpler example:
type X = number extends 4 ? true : false
// ^? - type X = false
4 extends number, not the other way around
Thank you. In this type hero challenge, the solution for isTuple does this type IsTuple<T> = [T] extends [never] ? false : T extends readonly unknown[] ? number extends T["length"] ? false : true : false; What does it mean when it says number extends T["length"]? if number does not extend 4, why would you check if number extends T["length"] isn't that the same thing? https://typehero.dev/challenge/istuple/solutions/1713```
number extends T["length"] will be true when T is an arbitrary-length array type. try IsTuple<string[]> for example