Type Alias RequiredNonNullable<T>

RequiredNonNullable<T>: T extends object
    ? Required<{
        [P in keyof T]: NonNullable<T[P]>
    }>
    : T

Converts a type T that may have optional, nullable properties into a new type with only required properties, while also subtracting null from all possible property values.

type Foo = { bar?: string | undefined | null };
type RequiredNonNullableFoo = RequiredNonNullable<Foo>;
// RequiredNonNullableFoo -> { bar: string };

Type Parameters

  • T