Type Challenges Judge

Subsequence

提出詳細

type Subsequence<T extends any[], Acc extends readonly unknown[]=[]> = T extends [infer T1, ...infer T2] ? Subsequence<T2, [...Acc, T1]> | Subsequence<T2, Acc> : Acc
提出日時2023-09-18 13:39:13
問題Subsequence
ユーザーsankantsu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Subsequence<[1, 2]>, [] | [1] | [2] | [1, 2]>>, Expect<Equal<Subsequence<[1, 2, 3]>, [] | [1] | [2] | [1, 2] | [3] | [1, 3] | [2, 3] | [1, 2, 3] >>, ]