IsTuple
提出詳細
type Writable<T> = { -readonly [P in keyof T]: T[P] } type IsTuple<T> = [T] extends [never] ? false : Writable<T> extends unknown[] ? [...Writable<T>, Writable<T>[0]] extends T ? false : true : false
提出日時 | 2023-09-02 12:28:30 |
---|---|
問題 | IsTuple |
ユーザー | ookkoouu |
ステータス | 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>>, ]