Aller au contenu principal

Primitive

Primitive = string | number | boolean | symbol | bigint | null | undefined

Union of all JavaScript primitive types.

Useful for type guards and generic constraints.

Since

2.0.0


Example

function isPrimitive(value: unknown): value is Primitive {
return value === null || (typeof value !== "object" && typeof value !== "function");
}

isPrimitive("hello"); // true
isPrimitive(42); // true
isPrimitive({}); // false
isPrimitive([]); // false