reactive-forms
reactive-forms copied to clipboard
FormBuilder does not support nulls in `strictNullChecks` mode
Is this a regression?
No
Description
- Enable
strictNullChecks.
constructor(
private fb: FormBuilder
) {}
protected readonly noBueno = this.fb.group({
age: [null as string | null],
// ^^^^^^^^^^^^^^^^^ TS2322: Type string | null is not assignable to type string
});
protected readonly bueno = new FormGroup({
age: new FormControl(null as string | null),
// This works.
});
Another somewhat related issue is that by virtue of extending Angular's form builder, FormBuilder has nonNullable property that returns native Angular implementation and lacks extra functionality from @ngneat/reactive-forms.
This can be confusing when someone is migrating to strictNullChecks and is actively converting form by adding nonNullable to them.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in
Anything else?
Angular 19.0.0 Typescript 5.6.2 @ngneat/reactive-forms 5.0.2
Do you want to create a pull request?
No