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
Parameter | Type |
---|---|
type | T |
Returns
UnionType
<[Type
<"Null"
, null
, null
, NullError
, null
, NullError
>, T
]>