Type
NarrowField
@ng-forge/dynamic-forms
Narrow a field definition based on its type property.
Use this to get proper type inference when working with field unions.
Signature
type NarrowField<T> = T extends { type: infer TType } ? (TType extends AvailableFieldTypes ? ExtractField<TType> : T) : T;Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
T | - | - | - |
Examples
function processField<T extends RegisteredFieldTypes>(field: T): NarrowField<T> {
return field as NarrowField<T>;
}packages/dynamic-forms/src/lib/models/registry/field-registry.ts:155