components: Illegal state: Could not load the summary for directive ObserveContent

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Angular Material and the CDK’s latest release/master is compatible with Angular 5.0.0-rc.7+ and Angular CLI 1.5.0-rc.5+.

What is the current behavior?

Build fails with the following error:

ERROR in Error: Illegal state: Could not load the summary for directive ObserveContent in /Users/splaktar/Git/tf/webapp/node_modules/@angular/cdk/observers/typings/index.d.ts.

What are the steps to reproduce?

Unable to reproduce in Stackblitz. Closest I came was https://stackblitz.com/edit/angular-material-with-angular-v5 which gives no errors.

I was unable to get @angular/flex-layout to build since it requires a version from master or angular/flex-layout-builds which isn’t accessible to Stackblitz (since not on NPM). I’m not having that problem in my local build.

What is the use-case or motivation for changing an existing behavior?

Dev and production builds passing.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular CLI: 1.5.0-rc.5
Node: 6.11.0
OS: darwin x64
Angular: 5.0.0-rc.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

@angular/cdk: 2.0.0-beta.12-0ea4370
@angular/cli: 1.5.0-rc.5
@angular/flex-layout: 2.0.0-beta.9-99e7450
@angular/material: 2.0.0-beta.12-0ea4370
@angular-devkit/build-optimizer: 0.0.31
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.34
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0-rc.5
@schematics/angular: 0.0.48
typescript: 2.4.2
webpack: 3.8.1

I also tried with CDK and material2 on beta.12.

Is there anything else we should know?

No

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 35 (15 by maintainers)

Most upvoted comments

OK, after numerous hours working on a reproduction and then changing code/config one at a time and rebuilding in AOT mode… I have finally solved this.

In my tsconfig.app.json file, I had the following:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    ...
    "rootDir": ".",
    ...
  },
  ...
}

This had been here for 6+ months w/o any issues.

According to the TypeScript docs, this flag is for:

–rootDir | string | (common root directory is computed from the list of input files) | Specifies the root directory of input files. Only use to control the output directory structure with --outDir.

I have no idea if this was something that was part of the CLI at some point, or if it was some custom config added to fix a previous issue.

But just removing this single line of config, and my AOT build failures with the CDK are now solved!

In my case it did not help. I have "rootDir": "src" in my tsconfig and cannot simply remove this line.

@HarshMathur Thank you for your solution , it really helps me a lot . I think default tsconfig.ts doesn’t include those *.ts in node_modules document , since it doesn’t have “files” and “includes” options.

any other solves? editing the json doesn’t work for me

I have also ran into this issue when I installed one npm package called ‘ng-pick-datetime’. I managed to solve this issue by adding these two paths in include array of tsconfig.json:

{
  "compileOnSave": false,
  "include": ["node_modules/ng-pick-datetime/node_modules/@angular/cdk/**/typings/index.d.ts", "node_modules/@angular/cdk/**/typings/index.d.ts", "src/**/*.ts"],
  "exclude": ["**/*.spec.ts"],
  "compilerOptions": {
       ........
  }
}

So I think it can fix the issue.

@Splaktar sorry for late answer, after some investigation I have created a new project with upgraded versions so with angular(7.2.13) and material(7.3.8) and I cannot reproduce the issue anymore. If I meet with the same issue, then I update my comment. Thanks for comments

I can confirm that setting skipTemplateCodegen to true will make the error go away.

But this is because the error will only appear if skipTemplateCodegen is set to false.

$ grep skipTemplateCodegen node_modules/@angular -R
node_modules/@angular/compiler-cli/src/transformers/compiler_host.js:            // if skipTemplateCodegen is set and fullTemplateTypeCheck is not yet set,
node_modules/@angular/compiler-cli/src/transformers/compiler_host.js:            if (this.options.skipTemplateCodegen && !this.options.fullTemplateTypeCheck) {
node_modules/@angular/compiler-cli/src/transformers/api.d.ts:    skipTemplateCodegen?: boolean;
node_modules/@angular/compiler-cli/src/perform_compile.js:            if (options.skipTemplateCodegen) {
node_modules/@angular/compiler-cli/src/ngtools_api2.d.ts:    skipTemplateCodegen?: boolean;

While debugging I also ended up in transformers/compiler_host.js, but didn’t find the actual reason for failure yet.

@Splaktar thanks a lot. This solved my issue

Also you probably won’t ever be able to reproduce on stackblitz since it’s almost certainly AOT-related