#Variable generic input length?
6 messages · Page 1 of 1 (latest)
its possible by using an array and mapped types or recursion to loop over it
type Intersection<T> = T extends [infer Head, ...infer Tail]
? Head & Intersection<Tail>
: unknown;
type X = Intersection<[{a:string}, { b: number}]>
!ts X
type X = {
a: string;
} & {
b: number;
} /* 5:6 */```
Thanks, @upbeat coral!