API reference@evolu/commonType › nullOr

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

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

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);