Type Challenges Judge

Tuple Filter

提出詳細

type IsFiltered<T, F> = [T] extends [never] ? true : T extends F ? true : false type FilterOut<T extends any[], F> = T extends [infer T1, ...infer T2] ? IsFiltered<T1,F> extends true ? FilterOut<T2,F> : [T1, ...FilterOut<T2,F>] : []
提出日時2023-09-21 00:55:15
問題Tuple Filter
ユーザーsankantsu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<FilterOut<[], never>, []>>, Expect<Equal<FilterOut<[never], never>, []>>, Expect<Equal<FilterOut<['a', never], never>, ['a']>>, Expect<Equal<FilterOut<[1, never, 'a'], never>, [1, 'a']>>, Expect<Equal<FilterOut<[never, 1, 'a', undefined, false, null], never | null | undefined>, [1, 'a', false]>>, Expect<Equal<FilterOut<[number | null | undefined, never], never | null | undefined>, [number | null | undefined]>>, ]