ConstraintField
ConstraintField<
TDoc> =unknownextendsTDoc?string: keyofDeclaredKeys<TDoc> &string
Defined in: packages/core/src/access/constraintTypes.ts:80
A constrainable field name for TDoc: its declared fields, degrading to string
when the document type is unresolved.
Two widenings are deliberately handled differently.
Before vex generate runs, DocumentBySlug falls back to
Record<string, unknown>, so a resource’s document type resolves to unknown —
and keyof unknown is never, which would make every field name unwritable.
unknown extends TDoc is true only for unknown/any, so this widens exactly
in the pre-generation case.
After generation the document type is real but still has VexDocument’s index
signature, so a bare keyof would collapse to string — no completion, and a
misspelled field silently accepted with an unknown value. DeclaredKeys
strips it, which is what makes q.eq(" offer the resource’s actual fields and
q.eq("tset", …) an error.
Type Parameters
Section titled “Type Parameters”TDoc
Document shape, or unknown when the registry is unaugmented.