API Reference / @evolu/common / Type / nullOr

Function: nullOr()

function nullOr<T>(type): UnionType<[Type<"Null", null, null, NullError, null, NullError>, T]>;

Defined in: packages/common/src/Type.ts:3085

union(null, T) Type.

Example

const NullOrString = nullOr(String);
NullOrString.from("hello"); // ok("hello")
NullOrString.from(null); // ok(null)
NullOrString.from(42); // err(...)

Type Parameters

Type Parameter
T extends AnyType

Parameters

ParameterType
typeT

Returns

UnionType<[Type<"Null", null, null, NullError, null, NullError>, T]>

Was this page helpful?