Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescript make every property of an object nullable

// 1 level depth
type Nullable<T> = { [K in keyof T]: T[K] | null };

// deep by recurisve call
type DeepNullable<T> = {
  [K in keyof T]: DeepNullable<T[K]> | null;
};
Source by typeofnan.dev #
 
PREVIOUS NEXT
Tagged: #typescript #property #object #nullable
ADD COMMENT
Topic
Name
7+4 =