Typegen types
Types for source type generation and the typegen:field plugin hook.
Types used by generateSourceTypes() / writeSourceTypes() and the typegen:field hook.
import type {
TypegenFieldContext,
GenerateSourceTypesOptions,
WriteSourceTypesOptions,
} from 'comark-content'TypegenFieldContext
Payload for the typegen:field hook. Plugins mutate type in place and register imports through imports.
interface TypegenFieldContext {
source: string
path: string[]
schema: JsonSchema
layer: 'data' | 'row'
type: string
imports: TypegenImportCollector
}| Field | Description |
|---|---|
source | Source name being rendered. |
path | Field path inside the schema (e.g. ['items', 'answer']). |
schema | JSON Schema node for this field. |
layer | 'data' for get() shapes; 'row' for flattened query columns. |
type | Mutable TS type string — starts as the default from JSON Schema. |
imports | Call imports.add('comark', 'MarkdownDocument') to emit extra import type lines. |
See markdown-fields for a complete example.
GenerateSourceTypesOptions
Options passed to generateSourceTypes(content, options?).
| Option | Type | Default | Description |
|---|---|---|---|
moduleName | string | 'comark-content' | Module specifier augmented in the generated declare module block. |
paths | boolean | true | Emit a ContentPaths map (path → data type). Pass false on very large sites. |
WriteSourceTypesOptions
Extends GenerateSourceTypesOptions with output location options for writeSourceTypes(content, options?).
| Option | Type | Default | Description |
|---|---|---|---|
outDir | string | '.' | Directory for the generated file. |
fileName | string | 'comark-content.d.ts' | File name inside outDir. |
outFile | string | — | Explicit path; overrides outDir / fileName. |