Skip to content

Nullable<T> ​

ts
type Nullable<T> = T extends object ? NullableObject<T> : T extends unknown[] ? NullableArray<T> : T | null;

Defined in: types.ts:315

Makes all properties at the first level nullable by adding null. Unlike DeepNullable, this only applies to the immediate properties, not nested ones.

Type Parameters ​

Type ParameterDescription
TType to make nullable

Example ​

ts
type Original = { name: string; address: { street: string } };
type Result = Nullable<Original>;
// Result: { name: string | null; address: { street: string } | null }