UNPKG

415 BTypeScriptView Raw
1import {Except} from './except';
2
3/**
4Merge two types into a new type. Keys of the second type overrides keys of the first type.
5
6@example
7```
8import {Merge} from 'type-fest';
9
10type Foo = {
11 a: number;
12 b: string;
13};
14
15type Bar = {
16 b: number;
17};
18
19const ab: Merge<Foo, Bar> = {a: 1, b: 2};
20```
21*/
22export type Merge<FirstType, SecondType> = Except<FirstType, Extract<keyof FirstType, keyof SecondType>> & SecondType;