Function: resolveFieldMapping()
resolveFieldMapping<
TComponents>(fieldKey,componentName,componentConfig):object
Defined in: packages/codegen/src/generate.ts:180
Resolve the component name and override config for a single FormField key.
Walks the componentConfig.fields map (by exact key, then normalized key) to
find a per-field override, then falls back to the componentConfig.components.overrides
map keyed by component name. Returns { source: 'none' } when no config is present.
Type Parameters
TComponents
TComponents extends Record<string, unknown>
Parameters
fieldKey
string
Dot-path key from FormField.key (e.g. 'address.street').
componentName
string | undefined
Inferred component name from the schema walker.
componentConfig
any
Optional ZodFormsConfig with fields and components overrides.
Returns
object
Resolved component name, override config, and the resolution source.
componentName?
optionalcomponentName?:string
componentOverride?
optionalcomponentOverride?:any
override?
optionaloverride?:any
source
source:
"fields"|"components"|"none"
Use When
- Building a custom codegen backend that needs the same override resolution logic as the CLI
- Writing tests that verify field-to-component mapping for a given config
Avoid When
- You are using the CLI or Vite plugin — this is called internally and you don't need it
Pitfalls
- NEVER assume
source: 'none'means the field has no component — the schema walker may have inferred one;resolveFieldMappingonly resolves user-provided config overrides