angular: StaticSymbolResolver - TypeError: Cannot read property 'length' of undefined

I’m submitting a … (check one with “x”)

[ x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When trying to do an AOT compilation the following error is received:

Starting compilation using the angular compiler.
Angular compilation done, starting webpack bundling.
TypeError: Cannot read property 'length' of undefined
    at StaticSymbolResolver.resolveSymbol (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:26000:37)
    at StaticReflector.findSymbolDeclaration (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:25260:71)
    at StaticReflector.importUri (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:25235:54)
    at StaticAndDynamicReflectionCapabilities.importUri (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:25150:115)
    at Reflector.importUri (/Users/Documents/workspace/myapp/node_modules/@angular/core/bundles/core.umd.js:2189:94)
    at identifierModuleUrl (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:1993:26)
    at _TsEmitterVisitor._visitIdentifier (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:20359:46)
    at _TsEmitterVisitor.visitExternalExpr (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:20058:18)
    at ExternalExpr.visitExpression (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:14790:28)
    at /Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19856:64
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitAllObjects (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19872:17)
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitAllExpressions (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19856:18)
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitInvokeMethodExpr (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19604:18)
    at InvokeMethodExpr.visitExpression (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:14700:28)
    at /Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19856:64
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitAllObjects (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19872:17)
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitAllExpressions (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19856:18)
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitInstantiateExpr (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19663:18)
    at InstantiateExpr.visitExpression (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:14745:28)
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitWritePropExpr (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19582:24)
    at WritePropExpr.visitExpression (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:14661:28)
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitExpressionStmt (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19438:23)
    at ExpressionStatement.visitStatement (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:15156:28)
    at /Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19885:62
    at Array.forEach (native)
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitAllStatements (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19885:24)
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitIfStmt (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19479:22)
    at IfStmt.visitStatement (/Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:15301:28)
    at /Users/Documents/workspace/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:19885:62
    at Array.forEach (native)

Expected behavior

Checks for the undefined object or throws a more meaningful error message.

In its current form, I have no idea what is wrong…

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Easier debugging

Please tell us about your environment:

OS X Angular Class Webpack AOT NPM

  • Angular version: 2.0.X

Angular 2.4.9

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5] TS 2.2.1 “target”: “es5”, “module”: “es2015”,

  • Node (for AoT issues): node --version = Node 7.5.0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Thank you very much for this thread. I’m on 4.2.4 and was getting a similar error:

ERROR in Internal error: unknown identifier undefined

This is a year old app that was started before AOT so we are having to unwind some bad practices. We had this in our App Module providers section:

    WindowService,
    {
      provide: Window,
      useValue: window
    }

I got rid of the bad provide and that fixed it.