Angular バージョン9 がリリースされたのでアップデートしてみた



2020年2月7日(金)にAngularバージョン9がリリースされたので早速アップデートした。  
以下ブログにアップデートの概要が記載されていたの参考にしながら進めた。  

https://blog.angular.io/version-9-of-angular-now-available-project-ivy-has-arrived-23c97b63cfa3

## 手順

### 現バージョン確認する

``` PowerShell
>ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 8.3.25
Node: 11.14.0
OS: win32 x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
```

- Angular: 8.2.14
- Node: 11.14.0

Angular v8の最終リリースにしてからAngular v9へアップデートすることが推奨されてるのでなっていなければバージョンをあげる。  

``` PowerShell
// v8の最終リリースバージョンにアップデートする。
ng update @angular/core@8 @angular/cli@8
```

Node v10.13以降のものを使用してください。

### Angularバージョン9へアップデート

``` PowerShell
ng update @angular/core @angular/cli

```

@でバージョン指定しなくても上記コマンドで最新バージョンを指定してくれる。  

#### 結果

``` PowerShell
ng update @angular/core @angular/cli
The installed Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.


Installing packages for tooling via npm.
Installed packages for tooling via npm.
Using package manager: 'npm'
Collecting installed dependencies...
Found 30 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular/cli @ "9.0.4" (was "8.3.25")...
    Updating package.json with dependency @angular/core @ "9.0.4" (was "8.2.14")...
    Updating package.json with dependency @angular-devkit/build-angular @ "0.900.4" (was "0.803.25")...
    Updating package.json with dependency @angular/language-service @ "9.0.4" (was "8.2.14")...
    Updating package.json with dependency @angular/compiler-cli @ "9.0.4" (was "8.2.14")...
    Updating package.json with dependency zone.js @ "0.10.2" (was "0.9.1")...
    Updating package.json with dependency @angular/router @ "9.0.4" (was "8.2.14")...
    Updating package.json with dependency @angular/compiler @ "9.0.4" (was "8.2.14")...
    Updating package.json with dependency @angular/common @ "9.0.4" (was "8.2.14")...
    Updating package.json with dependency rxjs @ "6.5.4" (was "6.4.0")...
    Updating package.json with dependency @angular/forms @ "9.0.4" (was "8.2.14")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "9.0.4" (was "8.2.14")...
    Updating package.json with dependency @angular/animations @ "9.0.4" (was "8.2.14")...
    Updating package.json with dependency @angular/platform-browser @ "9.0.4" (was "8.2.14")...
    Updating package.json with dependency typescript @ "3.7.5" (was "3.5.3")...
UPDATE package.json (1289 bytes)
√ Packages installed successfully.
** Executing migrations of package '@angular/cli' **

> Angular Workspace migration.
  Update an Angular CLI workspace to version 9.
UPDATE angular.json (3637 bytes)
UPDATE tsconfig.app.json (272 bytes)
UPDATE package.json (1292 bytes)
√ Packages installed successfully.
  Migration completed.

> Lazy loading syntax migration.
  Update lazy loading syntax to use dynamic imports.
  Migration completed.

> Replace deprecated 'styleext' and 'spec' Angular schematic options.
  Migration completed.

** Executing migrations of package '@angular/core' **

> Static flag migration.
  Removes the `static` flag from dynamic queries.
  As of Angular 9, the "static" flag defaults to false and is no longer required for your view and content queries.
  Read more about this here: https://v9.angular.io/guide/migration-dynamic-flag
  Migration completed.

> Missing @Injectable and incomplete provider definition migration.
  In Angular 9, enforcement of @Injectable decorators for DI is a bit stricter and incomplete provider definitions behave differently.
  Read more about this here: https://v9.angular.io/guide/migration-injectable
  Migration completed.

> ModuleWithProviders migration.
  In Angular 9, the ModuleWithProviders type without a generic has been deprecated.
  This migration adds the generic where it is missing.
  Read more about this here: https://v9.angular.io/guide/migration-module-with-providers
  Migration completed.

> Renderer to Renderer2 migration.
  As of Angular 9, the Renderer class is no longer available.
  Renderer2 should be used instead.
  Read more about this here: https://v9.angular.io/guide/migration-renderer
  Migration completed.

> Undecorated classes with decorated fields migration.
  As of Angular 9, it is no longer supported to have Angular field decorators on a class that does not have an Angular decorator.
  Read more about this here: https://v9.angular.io/guide/migration-undecorated-classes
  Migration completed.

> Undecorated classes with DI migration.
  As of Angular 9, it is no longer supported to use Angular DI on a class that does not have an Angular decorator.
  Read more about this here: https://v9.angular.io/guide/migration-undecorated-classes
  Migration completed.


Your project has been updated to Angular version 9!
For more info, please see: https://v9.angular.io/guide/updating-to-version-9
```

無事v9にあがりました。