Type alias Assign<T, Arr>

Assign<T, Arr>: Arr extends [infer S, ...(infer E)]
    ? Assign<S extends object
        ? __Merge<T, S>
        : T, E>
    : T

Copies all enumerable own properties from one target object to a source array of objects.

Type Parameters

  • T extends Record<string, unknown>
  • Arr extends unknown[]

Example

type T = Assign<{ a: 'd'; d: 'd' }, [{ a: 'a' }, { b: 'b' }, { c: 'c' }]>
// Result:
{
a: 'a';
b: 'b';
c: 'c';
d: 'd';
}