Skip to content

Utility types ​

TypeNotes
Infer<typeof schema>The value type of a schema as stored: plain data, without $refSchema on references
Parsed<typeof schema>The value of a parse result, and what parseOrThrow and the loaders return: Infer plus $refSchema on every reference value
OutputOf<typeof schema>The same as Infer
Schema<Output>Base type of every schema; ObjectSchema, DocumentSchema, ArraySchema, ... extend it
DocumentSchemaOf<Value>A document schema annotated by its value type
ObjectSchemaOf<Value>An object schema annotated by its value type
DocumentValue{_type: string; _id?: string; _rev?: string; _createdAt?: string; _updatedAt?: string}
ReferenceValue<T>The value of a reference() to a schema of type T
ArrayValue<T>T[], with _key added to object elements
TypedObjectSchemaAny object schema with a _type literal; use as a constraint in custom creators
ObjectUnionSchemaAny union() of typed objects, references, images, files or blocks
PrimitiveSchemaAny string, number, boolean, date, date-time or literal schema
PrimitiveUnionSchemaAny union() of primitives
ObjectLikeSchemaAny object, document, reference, block, image or file schema
ArraySchema<T>The schema type array() returns for an element schema of type T
StandardSchemaV1The Standard Schema interface, the same as in @standard-schema/spec

The type guards (isObjectSchema, isDocumentSchema, isOptionalSchema, ...) are exported for code that walks schemas, along with getInstanceName(schema), which returns the _type literal of an object or document schema, or undefined if it has none.