typelab / assertions / IsNullable
type IsNullable<T> = IsAny<T> extends true ? false : IsNever<T> extends true ? false : IsUnknown<T> extends true ? false : [null] extends [T] ? true : false;Checks if a given type T has null type.
| Type Parameter | Description |
|---|---|
|
|
The type to be checked. |
true if T has null type, false otherwise.
type Valid = IsNullable<string | null>; // true
type Invalid = IsNullable<string>; // false