UNPKG

416 BTypeScriptView Raw
1/**
2 * Merge Objects Array
3 *
4 * @example
5 * // if array
6 * [{ a: {}, b: {} }, { c: {} }] => { a: {}, b: {}, c: {} }
7 *
8 * // if object
9 * {} => {}
10 */
11export type MergeObjectsArray<T> = T extends Array<unknown>
12 ? {
13 [K in keyof T[number]]: T[number][K];
14 }
15 : T;
16
17/**
18 * If the first type is of type `unknown`, change it to the second type.
19 */
20export type IfUnknown<T, X> = unknown extends T ? X : T;
21
22