UNPKG

419 BTypeScriptView Raw
1/**
2Returns a boolean for whether the given type is `null`.
3
4@example
5```
6import type {IsNull} from 'type-fest';
7
8type NonNullFallback<T, Fallback> = IsNull<T> extends true ? Fallback : T;
9
10type Example1 = NonNullFallback<null, string>;
11//=> string
12
13type Example2 = NonNullFallback<number, string>;
14//=? number
15```
16
17@category Type Guard
18@category Utilities
19*/
20export type IsNull<T> = [T] extends [null] ? true : false;