angular-cn/aio/content/guide/updating-to-version-11.md

6.7 KiB

Updating Angular

This guide contains information related to updating to the latest version of Angular.

Updating CLI Apps

For step-by-step instructions on how to update to the latest Angular release (and leverage our automated migration tools to do so), use the interactive update guide at update.angular.io.

Changes and Deprecations in Version 11

For information about Angular's deprecation and removal practices, see Angular Release Practices.

{@a breaking-changes}

New Breaking Changes

  • Remove deprecated support for IE 9, 10, and IE mobile. See PR 38931.
  • TypeScript 3.9 is no longer supported. Please update to TypeScript 4.0. See PR 39313.
  • NavigationExtras#preserveQueryParams has been removed from @angular/router. See PR 38762
  • CollectionChangeRecord has been removed from @angular/core. See PR 38668.
  • We changed the default value for relativeLinkResolution from 'legacy' to 'corrected' so that new applications are automatically opted-in to the corrected behavior from PR 22394. Applications which use the current default are updated by a migration to specify 'legacy' to ensure the current behavior is maintained when the default is updated. See PR 25609.
  • Fixed a bug in the router where the arguments for future and curr snapshots were reversed in the call to shouldReuseRoute when processing child routes. Usually this ordering mistake doesn't matter because most implementations of shouldReuseRoute just do an equality comparison between future and curr. However, some implementations actually do rely on values specifically on one of the two and will need to be updated. See PR 26949.
  • ViewEncapsulation.Native has been removed. Angular previously supported a view encapsulation mode ViewEncapsulaion.Native that was based on the v0 Shadow DOM Draft APIs. These APIs have been superceded by the final Shadow DOM APIs, which are enabled via ViewEncapsulation.ShadowDom. For background information about this change, see Web Components update: more time to upgrade to v1 APIs.
  • @angular/platform-webworker has been removed and will no longer be supported. See PR 38846.
  • @angular/platform-webworker is no longer supported. No further versions will be published. See PR 38846.
  • Updated the options for initialNavigation. For more information, see initialNavigation in the API documentation. See PR 33128.
  • DatePipe no longer rounds up fractional milliseconds. See PR 38009.
  • Locale data arrays are now read-only. See PR 30397.
  • The injected ControlValueAccessor for NG_VALUE_ACCESSOR is now readonly. See PR 29273.
  • The type of AbstractControl#parent now indicates that it may be null. See PR 32671.
  • Calling overrideProvider before initializing the TestBed will now throw an error. See PR 38717.
  • Types for many Angular built-in pipes have been either narrowed or expanded to be more accurate. For more information, see the corresponding Pipes API documentation. See PR 37447.
  • Directives in the @angular/forms package used to have any[] as a type of validators and asyncValidators arguments in constructors. Now these arguments are properly typed, so if your code relies on directive constructor types it may require some updates to improve type safety. See PR 38994.
  • routerLink now accepts undefined inputs. See PR 39151.
  • The async function from @angular/core/testing has been renamed to waitForAsync in order to avoid confusion with the native JavaScript async syntax. The existing function is deprecated and will be removed in a future version. See PR 37583.

{@a deprecations}

New Deprecations

Area API or Feature May be removed in
@angular/core/testing Rename async to waitForAsync v13

{@a removals}

New Removals of Deprecated APIs

The following APIs have been removed starting with version 11.0.0*:

Package API Replacement Notes
@angular/router NavigationExtras#preserveQueryParams no action needed NavigationExtras#preserveQueryParams has been removed from @angular/router.
@angular/core CollectionChangeRecord no action needed CollectionChangeRecord has been removed from @angular/core.
@angular/core ViewEncapsulation.Native no action needed Angular previously supported a view encapsulation mode ViewEncapsulaion.Native that was based on the v0 Shadow DOM Draft APIs. These APIs have been superceeded by the final Shadow DOM APIs, which are enabled via ViewEncapsulation.ShadowDom. For background information about this change, see Web Components update: more time to upgrade to v1 APIs.

{@a ivy}

Ivy features and compatibility

Since version 9, Angular Ivy is the default rendering engine. If you haven't heard of Ivy, you can read more about it in the Angular Ivy guide.

  • Among other features, Ivy introduces more comprehensive type-checking within templates. For details, see Template Type-checking.

  • For general guidance on debugging and a list of minor changes associated with Ivy, see the Ivy compatibility guide.

  • For help with opting out of Ivy, see the instructions here.