Skip to content

Commit

Permalink
Improve readability of Merge result (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
papb committed Jan 3, 2021
1 parent 673c1aa commit c0e163d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/merge.d.ts
@@ -1,4 +1,7 @@
import {Except} from './except';
import {Simplify} from './simplify';

type Merge_<FirstType, SecondType> = Except<FirstType, Extract<keyof FirstType, keyof SecondType>> & SecondType;

/**
Merge two types into a new type. Keys of the second type overrides keys of the first type.
Expand All @@ -19,4 +22,4 @@ type Bar = {
const ab: Merge<Foo, Bar> = {a: 1, b: 2};
```
*/
export type Merge<FirstType, SecondType> = Except<FirstType, Extract<keyof FirstType, keyof SecondType>> & SecondType;
export type Merge<FirstType, SecondType> = Simplify<Merge_<FirstType, SecondType>>;

0 comments on commit c0e163d

Please sign in to comment.