Type Challenges Judge

Length of Tuple

提出詳細

type Length<Arr extends readonly unknown[]> = Arr['length'];
提出日時2023-05-17 14:22:20
問題Length of Tuple
ユーザーmrsekut
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' const tesla = ['tesla', 'model 3', 'model X', 'model Y'] as const const spaceX = ['FALCON 9', 'FALCON HEAVY', 'DRAGON', 'STARSHIP', 'HUMAN SPACEFLIGHT'] as const type cases = [ Expect<Equal<Length<typeof tesla>, 4>>, Expect<Equal<Length<typeof spaceX>, 5>>, // @ts-expect-error Length<5>, // @ts-expect-error Length<'hello world'>, ]