Skip to main content

@terascope/types / utility

utility

Index

Interfaces

InterfaceDescription
AnyObjectA simple object with any values
EmptyObject-
ListOfRecursiveArraysOrValuesA simple definitions of array
ManyA simple definitions of array
RecursiveArrayA simple definitions of array

Type Aliases

Diff<T, U>

Diff<T, U>: T extends U ? never : T

Remove types from T that are assignable to U

Type parameters

Type parameter
T
U

Source

utility.ts:79


Filter<T, U>

Filter<T, U>: T extends U ? T : never

Remove types from T that are NOT assignable to U

Type parameters

Type parameter
T
U

Source

utility.ts:84


FilteredResult<T, I, E>

FilteredResult<T, I, E>: { [P in keyof T]: P extends I ? T[P] : P extends E ? never : T[P] }

Filters the keys of an object (T), by list of included keys (I) and excluded (E)

Type parameters

Type parameter
T
I extends keyof T
E extends keyof T

Source

utility.ts:94


Maybe<T>

Maybe<T>: T | Nil

Type parameters

Type parameter
T

Source

utility.ts:46


Nil

Nil: null | undefined

Source

utility.ts:45


Omit<T, K>

Omit<T, K>: Pick<T, Exclude<keyof T, K>>

Omit the properties available to type. Useful for excluding properties from a type

Example

`Omit<{ a: number, b: number, c: number }, 'b'|'c'> // => { a: 1 }`

Type parameters

Type parameter
T
K extends keyof T

Source

utility.ts:7


Optional<T, K>

Optional<T, K>: { [P in keyof T]: P extends K ? NonNullable<T[P]> | undefined : NonNullable<T[P]> }

Like Partial but makes certain properties optional

Example

`Optional<{ a: number, b: number }, 'b'>`

Type parameters

Type parameter
T
K extends keyof T

Source

utility.ts:41


Override<T1, T2>

Override<T1, T2>: { [P in keyof T1]: P extends keyof T1 ? T2[P] : T1[P] }

Override specific properties on a type

Example

`Override<{ a: number, b: number }, { b: string }>`

Type parameters

Type parameter
T1
T2 extends { [P in keyof T2]: P extends keyof T1 ? T2[P] : never }

Source

utility.ts:23


Overwrite<T1, T2>

Overwrite<T1, T2>: { [P in Exclude<keyof T1, keyof T2>]: T1[P] } & T2

Overwrite a simple type with different properties. Useful changing and adding additional properties

Example

`Overwrite<{ a: number, b: number }, { b?: number }>`

Type parameters

Type parameter
T1
T2

Source

utility.ts:15


PartialDeep<T>

PartialDeep<T>: { [P in keyof T]?: PartialDeep<T[P]> }

A deep partial object

Type parameters

Type parameter
T

Source

utility.ts:72


Required<T, K>

Required<T, K>: { [P in keyof T]: P extends K ? NonNullable<T[P]> : NonNullable<T[P]> | undefined }

Like Partial but makes certain properties required

Example

`Required<{ a: number, b: number }, 'b'>`

Type parameters

Type parameter
T
K extends keyof T

Source

utility.ts:32


Unpacked<T>

Unpacked<T>: T extends infer U[] ? U : T extends (...args) => infer U ? U : T extends Promise<infer U> ? U : T

From https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-inference-in-conditional-types

Type parameters

Type parameter
T

Source

utility.ts:103


Unwrapped<T>

Unwrapped<T>: NonNullable<T>

Type parameters

Type parameter
T

Source

utility.ts:47


ValueOf<T>

ValueOf<T>: T[keyof T]

Get the types object (the opposite of keyof)

Type parameters

Type parameter
T

Source

utility.ts:89


WithoutNil<T>

WithoutNil<T>: { [P in keyof T]: T[P] extends Nil ? never : T[P] }

Without null or undefined properties

Type parameters

Type parameter
T

Source

utility.ts:52