Kristiyan Kostadinov 190fa07b9a feat(router): add migration for ActivatedRouteSnapshot.fragment (#41092)
Adds a migration that casts the value of `ActivatedRouteSnapshot.fragment` to be non-nullable.

Also moves some code from the `AbstractControl.parent` migration so that it can be reused.

Relates to #37336.

PR Close #41092
2021-03-23 11:18:00 -07:00
..

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.
  }
}