type-fest/source/is-null.d.ts
2025-11-30 04:44:57 +07:00

23 lines
431 B
TypeScript

/**
Returns a boolean for whether the given type is `null`.
@example
```
import type {IsNull} from 'type-fest';
type NonNullFallback<T, Fallback> = IsNull<T> extends true ? Fallback : T;
type Example1 = NonNullFallback<null, string>;
//=> string
type Example2 = NonNullFallback<number, string>;
//=> number
```
@category Type Guard
@category Utilities
*/
export type IsNull<T> = [T] extends [null] ? true : false;
export {};