Skip to main content

Module: Types

Type Aliases

Effect

Ƭ Effect<Function>: (...args: Parameters<Function>) => void

Type parameters

NameType
Functionextends VariadicFunction

Type declaration

▸ (...args): void

A simple side effect function descriptor.

Parameters
NameType
...argsParameters<Function>
Returns

void


Flatten

Ƭ Flatten<Source>: keyof Source extends keyof any[] ? `${number}` : keyof Source | keyof { [Key in keyof Source as Key extends string ? Source[Key] extends Record<string, unknown> ? `${Key}.${Flatten<Source[Key]>}` : Source[Key] extends any[] ? Source[Key] extends any[][] | Record<string, unknown>[] ? `${Key}.${number}` | `${Key}.${number}.${Flatten<Source[Key][number]>}` : `${Key}.${number}` : Key : never]: never }

Recursively flattens object type to a union of its keys combined through dot-notation.

Type parameters

NameType
Sourceextends Record<string, unknown> | any[]

Flattenable

Ƭ Flattenable: Record<string, unknown> | any[]

Type subjective to flattening.


Gradual

Ƭ Gradual<T>: T extends [...(infer R), any] ? R["length"] extends 0 ? T : T | Gradual<R> : T

Gradual defines a tuple type which accepts any amount of entries from the original one.

Gradual<[1, 2, 3]> === [1] | [1, 2] | [1, 2, 3]

Type parameters

NameType
Textends any[] | readonly any[]

Last

Ƭ Last<T>: T extends [...any[], infer L] ? L : any

Picks the last entry from the tuple or array.

Type parameters

NameType
Textends any[]

Map

Ƭ Map<From, To>: (value: From) => To

Type parameters

Name
From
To

Type declaration

▸ (value): To

A type of a function which maps the original value type to another one.

Parameters
NameType
valueFrom
Returns

To


Slice

Ƭ Slice<T, C>: T["length"] extends C ? T : T extends readonly [...Tuple<C>, ...(infer S)] ? S : T extends [...Tuple<C>, ...(infer S)] ? S : T

Removes C amount of T elements from the start.

Type parameters

NameType
Textends any[] | readonly any[]
Cextends number

Trim

Ƭ Trim<T, C>: T["length"] extends C ? T : T extends readonly [...(infer S), ...Tuple<C>] ? S : T extends [...(infer S), ...Tuple<C>] ? S : T

Removes C amount of T elements from the end.

Type parameters

NameType
Textends any[] | readonly any[]
Cextends number

Tuple

Ƭ Tuple<L, T>: T extends { length: L } ? T : Tuple<L, [...T, any]>

Creates a tuple of specified length.

Gracefully borrowed from here

Type parameters

NameType
Lextends number
Textends any[] | readonly any[] = []

UnaryFunction

Ƭ UnaryFunction: (arg: any) => any

Type declaration

▸ (arg): any

A type of a function accepting exactly one argument

Parameters
NameType
argany
Returns

any


Unshift

Ƭ Unshift<T, I, E>: I extends 0 ? [E, ...Slice<T, 1>] : I extends Trim<T, 1>["length"] ? [...Trim<T, 1>, E] : [...Trim<T, Slice<T, I>["length"]>, E, ...Slice<Slice<T, I>, 1>]

Replaces T element on specified index I with E.

Type parameters

NameType
Textends any[] | readonly any[]
Iextends number
EE

VariadicFunction

Ƭ VariadicFunction: (...args: any[]) => any

Type declaration

▸ (...args): any

A type of a function accepting an arbitrary amount of arguments

Parameters
NameType
...argsany[]
Returns

any