Skip to content

ng build never exits when using an incompatible version of TypeScript #23233

Description

@jnizet

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Can't remember

Description

When using a incompatible version of TypeScript, ng build displays an error, but keeps running forever without exiting.

This is particularly problematic on the CI, when using tools like renovate which send PRs upgrading the version of TypeScript, and the build consumes precious minutes of CI doing nothing until it finally times out.

🔬 Minimal Reproduction

  • run ng new to create a new project
  • edit the package.json file and change the typescript version to 4.7.2
  • run npm install
  • run ng build
  • the command never exits

🔥 Exception or Error

The error being displayed (but not causing the process to exit) is

(node:86326) UnhandledPromiseRejectionWarning: Error: The Angular Compiler requires TypeScript >=4.4.2 and <4.7.0 but 4.7.2 was found instead.
    at checkVersion (file:///Users/jb/tmp/tscheck/node_modules/@angular/compiler-cli/bundles/chunk-4MML3U2F.js:254:11)
    at verifySupportedTypeScriptVersion (file:///Users/jb/tmp/tscheck/node_modules/@angular/compiler-cli/bundles/chunk-4MML3U2F.js:258:3)
    at new NgtscProgram (file:///Users/jb/tmp/tscheck/node_modules/@angular/compiler-cli/bundles/chunk-4MML3U2F.js:7235:7)
    at AngularWebpackPlugin.updateAotProgram (/Users/jb/tmp/tscheck/node_modules/@ngtools/webpack/src/ivy/plugin.js:327:32)
    at /Users/jb/tmp/tscheck/node_modules/@ngtools/webpack/src/ivy/plugin.js:204:24
    at Hook.eval [as call] (eval at create (/Users/jb/tmp/tscheck/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:20:1)
    at Hook.CALL_DELEGATE [as _call] (/Users/jb/tmp/tscheck/node_modules/tapable/lib/Hook.js:14:14)
    at Compiler.newCompilation (/Users/jb/tmp/tscheck/node_modules/webpack/lib/Compiler.js:1108:30)
    at /Users/jb/tmp/tscheck/node_modules/webpack/lib/Compiler.js:1153:29
    at eval (eval at create (/Users/jb/tmp/tscheck/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:31:1)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:86326) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:86326) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

🌍 Your Environment


Angular CLI: 13.3.7
Node: 14.18.1
Package Manager: npm 6.14.15
OS: darwin x64

Angular: 13.3.10
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1303.7
@angular-devkit/build-angular   13.3.7
@angular-devkit/core            13.3.7
@angular-devkit/schematics      13.3.7
@angular/cli                    13.3.7
@schematics/angular             13.3.7
rxjs                            7.5.5
typescript                      4.7.2

Anything else relevant?

Nope

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions