Skip to content

Commit

Permalink
feat(types): add Overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
unicornware committed May 25, 2021
1 parent 6932071 commit 61ec34f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type { OneOrMany } from './types/OneOrMany'
export type { OrNever } from './types/OrNever'
export type { OrPartial } from './types/OrPartial'
export type { OrPromise } from './types/OrPromise'
export type { Overwrite } from './types/Overwrite'
export type { PartialBy } from './types/PartialBy'
export type { PartialByRequired } from './types/PartialByRequired'
export type { Path, PathN, PathNT } from './types/Path'
Expand Down
16 changes: 16 additions & 0 deletions src/types/Overwrite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { ObjectPlain } from './ObjectPlain'

/**
* @file Types - Overwrite
* @module types/Overwrite
*/

/**
* Replaces the properties of `T` with those of `T1`.
*
* @template T1 - Object to update
* @template T2 - Object to update with
*/
export type Overwrite<T extends ObjectPlain, T1 extends ObjectPlain> = {
[K in keyof T]: K extends keyof T1 ? T1[K] : T[K]
} & {}

0 comments on commit 61ec34f

Please sign in to comment.