Type alias NullishPropertiesOf<T>

NullishPropertiesOf<T>: { [ P in keyof T]-?: undefined extends T[P] ? P : null extends T[P] ? P : never }[keyof T]

Returns all shallow properties that accept undefined or null. Does not include Optional properties, only undefined or null.

Example

type UndefinedProps = NullishPropertiesOf<{
id: number | undefined,
createdAt: string | undefined,
firstName: string | null, // nullable properties are included
lastName?: string, // optional properties are not included.
}>;

// is equal to

type UndefinedProps = 'id' | 'createdAt' | 'firstName';

Type Parameters

  • T

Generated using TypeDoc