API reference / @evolu/common / Type / undefinedOr
Function: undefinedOr()
function undefinedOr<T>(
type,
): UnionType<
[
Type<
"Undefined",
undefined,
undefined,
UndefinedError,
undefined,
UndefinedError
>,
T,
]
>;
Defined in: packages/common/src/Type.ts:3172
union(undefined, T)
Type.
Example
const UndefinedOrString = undefinedOr(String);
UndefinedOrString.from("world"); // ok("world")
UndefinedOrString.from(undefined); // ok()
UndefinedOrString.from(42); // err(...)
Type Parameters
Type Parameter |
---|
T extends AnyType |
Parameters
Parameter | Type |
---|---|
type | T |
Returns
UnionType
<[Type
<"Undefined"
, undefined
, undefined
, UndefinedError
, undefined
, UndefinedError
>, T
]>