DeepNullable<T>
ts
type DeepNullable<T> = T extends object ? DeepNullableObject<T> : T extends unknown[] ? DeepNullableArray<T> : T | null;Defined in: types.ts:272
Recursively makes all properties throughout a type tree nullable by adding null to each property.
Type Parameters
| Type Parameter | Description |
|---|---|
T | The type to make deeply nullable |
Example
ts
type Original = {
name: string;
address: {
street: string;
city: string;
}
};
type Result = DeepNullable<Original>;
// Result: {
// name: string | null;
// address: {
// street: string | null;
// city: string | null;
// } | null;
// }