EnsureJsonSerializable
TypeSignature
type EnsureJsonSerializable<T> = [FindNonJsonValue<T>] extends [never] ? T : "Error: type must be JSON-serializable (no Date, Map, Set, bigint, functions or symbols)";core/src/job-types/json-serializable.ts:69
Compile-time helper: resolves to T when T carries nothing that would be
lost in a JSON round-trip, otherwise to a descriptive error string that
surfaces at the call site of the consumer.
Codec adapters use this to constrain their stored type — the form their
encoders return — while leaving the runtime type free, as examples/validation/codec-zod
does with its schemas' input types:
TypeScript
schemas: EnsureJsonSerializable<StoredForm> extends string ? "Error: ..." : TIt follows the same rules as defineJobTypes, so unknown and any pass.
Type Parameters
- T