Open rimo030 opened 6 months ago
type RemoveAll<T extends any[], U> = T extends [U, ...infer R] ? RemoveAll<R, U> : T type FindEles<T extends any[], L extends any[] = []> = T extends [infer F, ...infer R] ? R extends [F, ...infer rest] ? FindEles<RemoveAll<rest, F>, L> : FindEles<R, [...L, F]> : L
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<FindEles<[1, 2, 2, 3, 3, 4, 5, 6, 6, 6]>, [1, 4, 5]>>, Expect<Equal<FindEles<[2, 2, 3, 3, 6, 6, 6]>, []>>, Expect<Equal<FindEles<[1, 2, 3]>, [1, 2, 3]>>, ]