-
Notifications
You must be signed in to change notification settings - Fork 27k
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
roger6106 and degloman