API reference › @evolu/common › Type › nullOr

function nullOr<ValueType extends TypeNode>(
  type: ValidateUnionTypeMember<ValueType>,
): UnionType<readonly [ValueType, LiteralType<null>]>;

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

Union Type containing the supplied Type and null.

Example

import { assertOk, String, nullOr } from "@evolu/common";

const NullableString = nullOr(String);

assertOk(NullableString.fromUnknown(null), null);