Repository navigation
--build-optimizer errors "Cannot read property 'type' of undefined" #7110
Copy link
Copy link
Closed
Labels
P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulImpacts a large percentage of users; if a workaround exists it is partial or overly painfuleffort2: medium (days)freq3: highseverity3: brokentype: bug/fix
Description
Bug Report or Feature Request (mark with an x)
- [ ] bug report -> please search issues before submitting
- [x] feature request
Versions.
$ ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.3.0-rc.0
node: 8.1.1
os: win32 x64
@angular/animations: 4.3.1
@angular/common: 4.3.1
@angular/compiler: 4.3.1
@angular/core: 4.3.1
@angular/forms: 4.3.1
@angular/http: 4.3.1
@angular/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.3.0-rc.0
@angular/compiler-cli: 4.3.1rxjs@^5.4.2:
version "5.4.2"
resolved "<registry>/rxjs/-/rxjs-5.4.2.tgz#2a3236fcbf03df57bae06fd6972fd99e5c08fcf7"
dependencies:
symbol-observable "^1.0.1"
Repro steps.
Use a mis-aligned rxjs import:
import { Observable } from 'rxjs/Rx';$ ng build --aot --prod --build-optimizerThe log given by the failure.
ERROR in ./node_modules/rxjs/observable/BoundCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
at Object.getEffectiveTypeAnnotationNode (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:9341:17)
at assignContextualParameterTypes (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:41652:25)
at checkFunctionExpressionOrObjectLiteralMethod (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:41948:29)
at checkExpressionWorker (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:42959:28)
at checkExpression (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:42898:42)
at checkExpressionCached (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:42779:38)
at checkReturnStatement (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45418:54)
at checkSourceElement (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:46763:28)
at Object.forEach (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:1506:30)
at checkBlock (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:44563:16)
at checkSourceElement (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:46742:28)
at checkFunctionExpressionOrObjectLiteralMethodDeferred (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:41990:21)
at checkDeferredNodes (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:46828:25)
at checkSourceFileWorker (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:46863:17)
at checkSourceFile (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:46842:13)
at Object.forEach (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:1506:30)
@ ./node_modules/rxjs/observable/bindCallback.js 2:32-68
@ ./node_modules/rxjs/add/observable/bindCallback.js
@ ./node_modules/rxjs/Rx.js
@ ./src/root.component.ts
@ ./src/$$_gendir/app.module.ngfactory.ts
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in ./node_modules/rxjs/observable/BoundNodeCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
at Object.getEffectiveTypeAnnotationNode (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:9341:17)
at assignContextualParameterTypes (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:41652:25)
at checkFunctionExpressionOrObjectLiteralMethod (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:41948:29)
at checkExpressionWorker (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:42959:28)
at checkExpression (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:42898:42)
at checkExpressionCached (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:42779:38)
at checkReturnStatement (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45418:54)
at checkSourceElement (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:46763:28)
at Object.forEach (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:1506:30)
at checkBlock (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:44563:16)
at checkSourceElement (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:46742:28)
at checkFunctionExpressionOrObjectLiteralMethodDeferred (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:41990:21)
at checkDeferredNodes (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:46828:25)
at checkSourceFileWorker (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:46863:17)
at checkSourceFile (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:46842:13)
at Object.forEach (...\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:1506:30)
@ ./node_modules/rxjs/observable/bindNodeCallback.js 2:36-76
@ ./node_modules/rxjs/add/observable/bindNodeCallback.js
@ ./node_modules/rxjs/Rx.js
@ ./src/root.component.ts
@ ./src/$$_gendir/app.module.ngfactory.ts
@ ./src/main.ts
@ multi ./src/main.tsDesired functionality.
Whether that rxjs syntax should be build success? I don't think so!
A better error message is good!
Mention any other details that might be useful.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulImpacts a large percentage of users; if a workaround exists it is partial or overly painfuleffort2: medium (days)freq3: highseverity3: brokentype: bug/fix
Activity
dherges commentedon Jul 25, 2017
After #7105, I have now a fresh working copy at dherges/ng-cli-build-optimizer-issue7110.
I will try to reproduce the issue there and then give an update.
rtm commentedon Jul 27, 2017
I had a similar problem and solved it by replacing
import { Observable } from 'rxjs/Rx';withimport { Observable } from 'rxjs/Observable';.dherges commentedon Jul 27, 2017
@rtm Yep, thanks! That's the cause!
@filipesilva Here's the repro: https://github.com/dherges/ng-cli-build-optimizer-issue7110/commit/4a19a56da0e9a77072395f0f70de3b28b54dc1a7
@Hanfrey FYI ... Fehler erkannt, Fehler gebannt! 🐎
filipesilva commentedon Jul 28, 2017
This shouldn't happen, and I think it's the same as angular/devkit#51. Will investigate.
chriszrc commentedon Jul 31, 2017
Hi,
So are you saying you could still import the entire rxjs library:
import { Observable } from 'rxjs/Rx';But still see tree-shaking and just get what you need? Would certainly be less verbose than having to import all the different operators individually given the alternative import
slubowsky commentedon Jul 31, 2017
Im getting same issue - but dont think the import is "mis-aligned". Im using a 3rd party library which imports Observable bindCallback like this:
import 'rxjs/add/observable/bindCallback';and then my build results in:
fix(@angular/cli): update build-optimizer
84 remaining items
filipesilva commentedon Nov 25, 2017
angular/devkit#299 should fix this.
filipesilva commentedon Nov 27, 2017
Fixed by angular/devkit#299, will be out on the next release.
patocardo commentedon Jan 19, 2018
I have the same problem and I couldn't solve it. In my case, it was caused by the use of
import { BehaviorSubject } from 'rxjs/Rx';I removed it and programmed my own subject class
mbark commentedon Jan 22, 2018
@patocardo Did you try
import { BehaviorSubject } from 'rxjs/BehaviorSubject';? That works fine for me.patocardo commentedon Jan 22, 2018
@mbark, thanks to the poor documentation, I didn't know of that alternative source. I'll try it.
By the way
import { BehaviorSubject } from 'rxjs/Rx';worked fine in development, the problem only appeared online.Thank you for the advice
fredgate commentedon Jan 23, 2018
You can configure TSLint to warn when there are imports like 'rxjs/Rx'. It avoids to meet problem when you use AOT instead of JIT.
fix(@angular/cli): update build-optimizer
brobert6 commentedon Apr 27, 2018
For me
import 'rxjs/Rx';
caused the problem. Specified the exact package that I want to import and it worked for me:
import 'rxjs/Rx';
vytautas-pranskunas- commentedon May 8, 2018
@jsubiratsgirbau i do not have problems importing Observable but there are problems in RXJS node_mdules in rxjs itself
mateosantosdev commentedon Sep 11, 2018
I've solved it installing typescript@2.6.1
angular-automatic-lock-bot commentedon Sep 8, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
fix(@angular/cli): update build-optimizer