'interface as Nullable

I've got the following types/interfaces:

type Nullable<T> = T | null;

export interface Employee {
  name: string;
  salary: number;
}

I don't want to define attributes of Employee to be Nullable, BUT the whole Employee should be Nullable.

Since I don't want do type everytime I use it as so Nullable<Employee>. I'd rather just type it as Employee which then would automatically be Employee | null



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source