generateVexTypes
generateVexTypes(
props):string
Defined in: packages/core/src/types/generateVexTypes.ts:84
Generates the full contents of vex.types.ts from a resolved VexConfig.
When there are no collections, returns only the auto-generated header. When collections are present, the output contains:
- Imports for
Id(from@convex/_generated/dataModel) andVexDocument(from@vexcms/core) - One
export interfaceper collection, extendingVexDocumentwith a brandedId<"slug">for_id export type CollectionSlug— union of all collection slugsexport type DocumentBySlug— map of slug to document interfacedeclare module '@vexcms/core'block that augmentsGeneratedVexTypes, narrowingCollectionSlugandDocumentBySluginside@vexcms/coreitself
Parameters
Section titled “Parameters”Input props.
config
Section titled “config”The fully resolved Vex configuration.
Returns
Section titled “Returns”string
The complete TypeScript source string to write to vex.types.ts.
Example
Section titled “Example”const config = defineConfig({ collections: [ defineCollection({ slug: "posts", fields: { title: text({ required: true }) } }), ],});const contents = generateVexTypes({ config });// Writes to vex.types.ts:// import type { Id } from "@convex/_generated/dataModel"// import type { VexDocument } from "@vexcms/core"// export interface PostsDocument extends VexDocument { _id: Id<"posts">; title: string }// export type CollectionSlug = "posts"// export type DocumentBySlug = { posts: PostsDocument }// declare module "@vexcms/core" { interface GeneratedVexTypes { ... } }- collectionConfigToInterface for the per-collection interface builder
- VexConfig for the resolved config shape