Repository navigation
Open
Labels
Milestone
Description
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
FormRecord is sometimes incorrectly inferred to be a FormGroup.
This is apparently caused by:
FormRecordclass actually extendsFormGroup- The way
ɵElementis implemented (first checks for instance ofFormGroup, beforeFormRecord)
Please provide a link to a minimal reproduction of the bug
This appeared as a TS error while working on #50750 (which adds a new method on FormRecord)
https://github.com/EmmanuelRoux/angular/tree/formrecord-clear
Revealed by some Angular's own tests, such as this one (extract below):
const c = fb.array([fb.record({bar: 'foo'})]);
{
type ControlsType = Array<FormRecord<FormControl<string|null>>>;
let t: ControlsType = c.controls; // <-- incorrectly inferred as controls of `FormGroup` instead of `FormRecord`
let t1 = c.controls;
t1 = null as unknown as ControlsType;
}Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run ng version)
Working on PR #50750 which adds a new method on `FormRecord` (but not on `FormGroup`)
Angular CLI: 16.0.0-rc.4
Node: 20.3.0 (Unsupported)
Package Manager: yarn 1.22.19
OS: darwin arm64
Angular: undefined
...
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1600.0-rc.4
@angular-devkit/build-angular 16.0.0-rc.4
@angular-devkit/core 16.0.0-rc.4
@angular-devkit/schematics 16.0.0-rc.4
@angular/build-tooling 0.0.0-5f06c4774df908ed69e1441f4ec63b898acf0c68
@angular/cdk 16.0.0-rc.2
@angular/cli 16.0.0-rc.4
@angular/material 16.0.0-rc.2
@angular/ng-dev <error>
@bazel/bazelisk 1.12.1
@bazel/buildifier 6.1.2
@bazel/concatjs 5.8.1
@bazel/esbuild 5.8.1
@bazel/ibazel v0.16.2
@bazel/jasmine 5.8.1
@bazel/protractor 5.8.1
@bazel/rollup 5.8.1
@bazel/runfiles 5.8.1
@bazel/terser 5.8.1
@bazel/worker 5.8.1
@schematics/angular 16.0.0-rc.4
rxjs 6.6.7
typescript 5.1.3
Anything else?
No response
Reacted by roger6106 and Dmytro Siriachenko
Activity
roger6106 commentedon Feb 22, 2024
I experienced this issue, which presented itself as not being able to remove FormControls from a FormRecord. I ended up finding this issue after seeing a question posted on Stack Overflow (along with the needed solution).
degloman commentedon May 31, 2024
I have the same issue, managed to fix it by replacing

fb.grouptonew FormGroup()EmmanuelRoux commentedon May 31, 2024
Hi, I think this will eventually be fixed by #50750
roger6106 commentedon May 28, 2025
It looks like that pull request was cancelled, and I can't find any sign of this issue being fixed anywhere else.
EmmanuelRoux commentedon May 28, 2025
Both PR have been cancelled by Angular team
JeanMeche commentedon May 28, 2025
There was a rebase issue, if you still have the branch locally you should be able to force-push / reopen a PR.
arturovt commentedon Sep 29, 2026
@JeanMeche this can be closed unless the type fix is wanted. The cause is branch order in ɵElement: FormGroup is checked before FormRecord, and FormRecord extends FormGroup, so a record always matches the group branch first. Moving the FormRecord branches above the FormGroup ones would fix it and is type-only.
It is still a compile-time behavior change in a maintained package, on a report with no duplicates since 2023, so it needs a presubmit to be worth it.