Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type Aliases

DeepPartial<T>: T extends Record<string, unknown> ? { [ K in keyof T]?: DeepPartial<T[K]> } : T

A type that recursively makes each property of T optional.

example
type Foo = { a: number };
type Bar = { foo: Foo };
type Baz = DeepPartial<Bar>; // { foo?: { a?: number } }

Type Parameters

  • T

DeepRequired<T, P>: T extends unknown[] ? T : T extends Record<string, unknown> ? Pick<T, Extract<keyof T, P[0]>> & Required<{ [ K in Exclude<keyof T, P[0]>]: NonNullable<DeepRequired<T[K], ShiftUnion<K, P>>> }> : T

A type that recursively makes each property of T required. Optionally excluding a nested path specified by a list of keys.

example
type Foo = { a?: { c?: number }, b?: string };
type Bar = { foo: Foo };
type Baz = DeepRequired<Bar, []>; // { foo: { a: { c: number }, b: string } }
type Baz = DeepRequired<Bar, ['a', 'c']>; // { foo: { a: { c?: number }, b: string } }
type Baz = DeepRequired<Bar, ['a'] | ['b']>; // { foo: { a: { c?: number }, b?: string } }

Type Parameters

  • T

  • P extends string[]

Listener<T>: ((event: T) => void)

Type Parameters

  • T

Type declaration

    • (event: T): void
    • Parameters

      • event: T

      Returns void

Predicate<T>: ((value: T) => boolean)

Type Parameters

  • T

Type declaration

    • (value: T): boolean
    • Defines a function that takes a value and returns true if the condition is satisfied, or false if it doesn't.

      Parameters

      • value: T

      Returns boolean

RequiredAndNonNullable<T>: Required<{ [ P in keyof T]: NonNullable<T[P]> }>

A type that extends Required that in addition to making fields not undefined, also makes them not nullable.

example
type Foo = { a?: number | null };
type Bar = RequiredAndNonNullable<Bar>; // { a: number }

Type Parameters

  • T