Type

ExtractField

@ng-forge/dynamic-forms

Extract a specific field type from RegisteredFieldTypes based on the type discriminant. This enables proper type narrowing when defining fields.

Signature

type ExtractField<T extends AvailableFieldTypes> = T extends keyof FieldTypeMap ? FieldTypeMap[T] : never;

Type Parameters

NameConstraintDefaultDescription
TAvailableFieldTypes--

Examples

// Extract a specific field type
type MyInputField = ExtractField<'input'>;

// Use in field definitions for proper props inference
const field: ExtractField<'input'> = {
  type: 'input',
  key: 'email',
  value: '',
  props: { type: 'email' } // Only input props allowed here
};