angular-cli: Build --watch failing on rebuild

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Angular CLI: 1.5.0
Node: 8.1.0
OS: darwin x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 2.0.0-beta.12
@angular/cli: 1.5.0
@angular/flex-layout: 2.0.0-beta.10
@angular/material: 2.0.0-beta.12
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.6.1
webpack: 3.8.1

Repro steps.

  1. Run in terminal: ./node_modules/.bin/ng build --aot --env=dev --watch
  2. -> The build is successful
  3. Add a new line to any source file
  4. The build will throw an error:
ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
    at tryReuseStructureFromOldProgram (/node_modules/typescript/lib/typescript.js:72100:26)
    at Object.createProgram (/node_modules/typescript/lib/typescript.js:71808:34)
    at AngularCompilerProgram._createProgramWithBasicStubs (/node_modules/@angular/compiler-cli/src/transformers/program.js:431:29)
    at /node_modules/@angular/compiler-cli/src/transformers/program.js:144:28
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)

The log given by the failure.

ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
    at tryReuseStructureFromOldProgram (/node_modules/typescript/lib/typescript.js:72100:26)
    at Object.createProgram (/node_modules/typescript/lib/typescript.js:71808:34)
    at AngularCompilerProgram._createProgramWithBasicStubs (/node_modules/@angular/compiler-cli/src/transformers/program.js:431:29)
    at /node_modules/@angular/compiler-cli/src/transformers/program.js:144:28
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)

Desired functionality.

Adding a new line shouldn’t break the build

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 10
  • Comments: 16 (3 by maintainers)

Most upvoted comments

The same error still shows up for current angular 5.2.x and @ngtools/webpack 1.10.1 if I use a TS version != 2.4.2. As Angular 5.2 officially supports TS 2.6 this is now a real bug, please reopen.

The current version of typescript supported is 2.4.2, please use that version for now. Support for later versions of TypeScript are being looked into.

I’m having the same problem after moving an imported .ts file outside the app structure (it acts as a shared module). This works in the first build and fails after a live rebuild.

Using a non-aot developer build seems to work just fine. I can reproduce the issue every time, here’s the log:

ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
    at tryReuseStructureFromOldProgram (/.../node_modules/typescript/lib/typescript.js:74285:26)
    at Object.createProgram (/.../node_modules/typescript/lib/typescript.js:73988:34)
    at AngularCompilerProgram._updateProgramWithTypeCheckStubs (/.../node_modules/@angular/compiler-cli/src/transformers/program.js:460:30)
    at /.../node_modules/@angular/compiler-cli/src/transformers/program.js:148:23
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)

This is not critical, but a major nuisance. Any help?

Hi Guys,

I also get this issue on change of source code like fixing an import reference.

I am using ng serve --aot

Regards, Tarek

Can confirm this is still a thing with Angular 6.0.9 and CLI 6.0.8, issue should be reopen