Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
531 bytes
|
Line | |
---|
1 | import {Except} from './except';
|
---|
2 | import {Simplify} from './simplify';
|
---|
3 |
|
---|
4 | type Merge_<FirstType, SecondType> = Except<FirstType, Extract<keyof FirstType, keyof SecondType>> & SecondType;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
---|
8 |
|
---|
9 | @example
|
---|
10 | ```
|
---|
11 | import {Merge} from 'type-fest';
|
---|
12 |
|
---|
13 | type Foo = {
|
---|
14 | a: number;
|
---|
15 | b: string;
|
---|
16 | };
|
---|
17 |
|
---|
18 | type Bar = {
|
---|
19 | b: number;
|
---|
20 | };
|
---|
21 |
|
---|
22 | const ab: Merge<Foo, Bar> = {a: 1, b: 2};
|
---|
23 | ```
|
---|
24 | */
|
---|
25 | export type Merge<FirstType, SecondType> = Simplify<Merge_<FirstType, SecondType>>;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.