Search code examples
angulartypescriptangular-cli

TypeScript update with Angular update from 16 to 17


I'm trying to upgrade Angular from 16 to 17. The upgrade guide says:

Make sure that you are using a supported version of TypeScript before you upgrade your application. Angular v17 supports TypeScript version 5.2 or later.

However, Angular 16 requires TypeScript >=4.9.3 <5.2 and if I run npm install -D [email protected] trying to install TypeScript 5.2 or later I get the error:

npm warn Could not resolve dependency:
npm warn peer typescript@">=4.9.3 <5.2" from @angular-devkit/[email protected]

Therefore, TypeScript upgrade fails because Angular 16 doesn't support it. If I stay in my current TypeScript version and run ng update @angular/core@17 @angular/cli@17 I get the following error:

Package "@angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=4.9.3 <5.2", would install "5.4.5").
✖ Migration failed: Incompatible peer dependencies found.

How do I get out of this situation?


Solution

  • The problem might be that you are trying to perform the update with the latest Angular CLI version. Try to use v17 instead:

    npx @angular/cli@17 update @angular/core@17 @angular/cli@17