-
-
Notifications
You must be signed in to change notification settings - Fork 0
type null
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
export type IsNull<T, True = true, False = false> = [T] extends [never] ? False
: [T] extends [null] ? True
: False;Checks if the type T is specifically null,
returning True if it is, and
False if not.
T-
True(default:true) -
False(default:false)
Types
import type { IsNull } from "@nick/is/type";
type A = IsNull<null>; // true
type B = IsNull<undefined>; // false
type C = IsNull<never>; // falseexport type OmitNull<T, Deep extends boolean = false> = T extends object ? {
[K in [object Object]]: Deep extends true ? OmitNull<T[K], Deep> : T[K]
} : T;Omit properties from an object type where the value is null. This relies on
the IsNever utility type.
T-
Deepextendsboolean(default:false)
Types
import type { OmitNull } from "@nick/is/type";
type A = { a: string; b: null; c: number };
type B = OmitNull<A>;
// ^? type B = { a: string; c: number }