type Nullable<T> = T | null;Type that allows a value to be T or null.
| Type Parameter | Default type | Description |
|---|---|---|
|
|
|
The original type. |
Union T and null
const example: Nullable<string> = null; // valid
const example2: Nullable<string> = undefined; // invalid