Muhammed Senussi
Muhammed Senussi
  • Muhammed Senussi
Typed Reactive Forms, TamedAngular

Typed forms are a clear improvement and the migration produces some genuinely confusing errors, most of which come from two misunderstandings.

Disabled controls and getRawValue

value excludes disabled controls, so its type is a partial. If you need everything, getRawValue() is what you want, and it is typed correctly. A great deal of the frustration people report is this one distinction, and the type system is being accurate rather than difficult.

Nullability is real

A control is nullable by default because reset() sets it to null. Use nonNullable: true when a reset should return to the initial value instead, which is usually what a form actually wants.

  • Build forms with FormBuilder.nonNullable to avoid repeating it on every control.
  • Define the form interface first and derive the group from it, rather than inferring the shape from a builder call and hoping.
  • For dynamic forms, FormRecord exists precisely because a FormGroup with unknown keys cannot be typed.

1 Comments

  • Lotte Jansen

    March 11, 2025

    The value versus getRawValue distinction explains about 80% of the complaints I have seen about typed forms.

Leave a comment