Skip to content

Commit

Permalink
feat(types): Union
Browse files Browse the repository at this point in the history
  • Loading branch information
unicornware committed Oct 15, 2021
1 parent d270a78 commit 59e1584
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ export type { default as Path } from './path.type'
export type { default as PickByType } from './pick-by-type.type'
export type { default as Primitive } from './primitive.type'
export type { default as Split } from './split.type'
export type { default as Union } from './union.type'
21 changes: 21 additions & 0 deletions src/types/union.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type ObjectPlain from './object-plain.type'

/**
* @file Type Definitions - Union
* @module tutils/types/Union
*/

/**
* Allow either type `T1` or `T2`.
*
* @template T1 - Object type 1
* @template T2 - Object type 2
*
* @see https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#union-types
*/
type Union<
T1 extends ObjectPlain = ObjectPlain,
T2 extends ObjectPlain = ObjectPlain
> = T1 & T2

export default Union

0 comments on commit 59e1584

Please sign in to comment.