Type Challenges Judge

IsTuple

提出詳細

type IsTuple<T> = [T] extends [never] ? false : T extends readonly [] | readonly [infer T1, ...infer T2] ? true : false
提出日時2023-09-18 03:30:51
問題IsTuple
ユーザーsankantsu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<IsTuple<[]>, true>>, Expect<Equal<IsTuple<[number]>, true>>, Expect<Equal<IsTuple<readonly [1]>, true>>, Expect<Equal<IsTuple<{ length: 1 }>, false>>, Expect<Equal<IsTuple<number[]>, false>>, Expect<Equal<IsTuple<never>, false>>, ]