aeec223db1
As of #32671, the type of `AbstractControl.parent` can be null which can cause compilation errors in existing apps. These changes add a migration that will append non-null assertions to existing unsafe accesses. ```` // Before console.log(control.parent.value); // After console.log(control.parent!.value); ``` The migration also tries its best to avoid cases where the non-null assertions aren't necessary (e.g. if the `parent` was null checked already). PR Close #39009 |
||
---|---|---|
.. | ||
BUILD.bazel | ||
README.md | ||
index.ts | ||
util.ts |
README.md
AbstractControl.parent
migration
As of Angular v11, the type of AbstractControl.parent
can be null. This migration automatically
identifies usages and adds non-null assertions.
Before
import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
@Component()
export class MyComponent {
private _control = new FormControl();
getParentValue() {
return this._control.parent.value; // <- Compilation error in v11.
}
}
After
import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
@Component()
export class MyComponent {
private _control = new FormControl();
getParentValue() {
return this._control.parent!.value; // <- Non-null assertion added during the migration.
}
}