Skip to content

ConstraintValue

ConstraintValue<TDoc, F> = unknown extends TDoc ? unknown : F extends keyof TDoc ? TDoc[F] : never

Defined in: packages/core/src/access/constraintTypes.ts:98

The value type for a constraint on field F of TDoc: the field’s own type, never when F is not a field of TDoc, and unknown when TDoc itself is unresolved.

The third case is what separates “you named a field that does not exist” (a real error, never) from “this project has not run vex generate yet” (not an error). Without it both collapse to never and no constraint can be written at all — including in packages/core’s own tests, which run against an unaugmented registry by design.

TDoc

Document shape, or unknown when the registry is unaugmented.

F extends string

The field name being constrained.