ng-packagr: fullTemplateTypeCheck: Cannot read property 'type' of null

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

angular/angular#19906

angular/angular#24143

How To Reproduce

Issue happens when fullTemplateTypeCheck is enabled.

https://angular.io/guide/aot-compiler#fulltemplatetypecheck

Error: TypeError: Cannot read property 'type' of null
    at C:\projects\material2\node_modules\@angular\compiler\bundles\compiler.umd.js:25385:26
    at Array.forEach (native)
    at removeSummaryDuplicates (C:\projects\material2\node_modules\@angular\compiler\bundles\compiler.umd.js:25384:11)
    at TemplateParser.tryParseHtml (C:\projects\material2\node_modules\@angular\compiler\bundles\compiler.umd.js:24393:51)
    at TemplateParser.tryParse (C:\projects\material2\node_modules\@angular\compiler\bundles\compiler.umd.js:24370:21)
    at TemplateParser.parse (C:\projects\material2\node_modules\@angular\compiler\bundles\compiler.umd.js:24332:44)
    at AotCompiler._parseTemplate (C:\projects\material2\node_modules\@angular\compiler\bundles\compiler.umd.js:29710:60)
    at AotCompiler._compileComponent (C:\projects\material2\node_modules\@angular\compiler\bundles\compiler.umd.js:29682:23)
    at C:\projects\material2\node_modules\@angular\compiler\bundles\compiler.umd.js:29528:55
    at Array.forEach (native)

The issue can be work-around’ed by setting fullTemplateTypeCheck: false

Expected Behaviour

Something, just anything better 😃

An error message … indicating where the problem in the code base.

Version Information

Angular CLI: 6.2.2
Node: 10.10.0
OS: linux x64
Angular: 6.1.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.8.2
@angular-devkit/schematics        0.8.2
@angular/cdk                      6.4.7
@angular/cli                      6.2.2
@ngtools/json-schema              1.1.0
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.1
@schematics/update                0.8.2
ng-packagr                        4.1.1
rxjs                              6.3.2
typescript                        2.9.2
webpack                           4.8.3

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 24 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I found one case where isSkipSelf of null relates to fullTemplateTypeCheck. Die to the error message I don’t know what piece of code causes the error. The error is supressed with fullTemplateTypeCheck: false

https://github.com/angular/angular/issues/20523

Issue appeared when i changed npm to pnpm since pnpm uses symlinks in node_modules

Angular 10 ng-packagr 10

Seems to still be around with ng-packagr@4.4.0

Just wanted to add that I got this same error with the angular 7.0.0-rc versions, but setting fullTemplateTypeCheck: false still suppressed the error exactly like @dherges said. But still no real info on the core issue.

Version Information

Angular CLI: 7.0.0-rc.2
Node: 8.11.3
OS: linux x64
Angular: 7.0.0-rc.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.9.0-rc.2
@angular-devkit/build-angular     0.9.0-rc.2
@angular-devkit/build-optimizer   0.9.0-rc.2
@angular-devkit/core              7.0.0-rc.2
@angular-devkit/schematics        7.0.0-rc.2
@angular/cdk                      7.0.0-rc.1
@angular/cli                      7.0.0-rc.2
@ngtools/json-schema              1.1.0
@ngtools/webpack                  7.0.0-rc.2
@schematics/angular               7.0.0-rc.2
@schematics/update                0.9.0-rc.2
ng-packagr                        4.2.0 *(see below)
rxjs                              6.3.3
typescript                        3.1.1
webpack                           4.19.1

EDIT FYI: Looks like ng-packagr@4.3.0 was published literally in the last hour, so I retried with that and the same issue still seems to exist.

For me, currently, it’s either "fullTemplateTypeCheck": false and then the error is:

Error during template compile of 'DemoRoutingModule'
Function calls are not supported in decorators but 'RouterModule' was called

Or, if i set fullTemplateTypeCheck to true, I get the very loved and detailed error:

ERROR: Cannot read property 'type' of null

This is a very annoying error! Please provide more info into the error, what exactly didn’t the compiler like?

I can confirm issues regarding symlinks. I’m running the latest Windows 10 Pro, Windows Terminal 1.0.1401.0 with the latest Powershell 7.0.1 and ng-packagr 5.7.1.

I use a symlink to C:\development in another folder, which triggers this error. If i go directly into C:\development, and retries, with no other changes, it works fine.

I did some digging, and I think the cause of the error is in the Angular Compiler (ngc), specifically removeSummaryDuplicates.

But the root issue is even deeper than that. I believe the problem has something to do with the StaticSymbolCache being inconsistent in how it sets the filePath of a symbol. When using PNPM, the cache contained two entries for NgClass (and many other symbols). One entry at the “actual” path (“node_modules/.pnpm/@angular/…”) and one entry at the hard-linked path (“node_modules/@angular/…”). Strangely, this doesn’t seem to be a problem when using npm link, even though that also uses symbolic links.

I really hope that the Angular team reconsiders fixing issues related to pnpm, especially since this issue has nothing to do with ngcc, which is their justification for not fixing this in the past (as far as I can tell, this won’t work any better when using Angular Linker).

I was really hoping that at the end of my digging I would be able to find a solution, but the compiler simply has too much complexity for me to find the source of this and an appropriate fix. I hope someone else has more success than me!