Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--build-optimizer errors "Cannot read property 'type' of undefined" #7110

Closed
dherges opened this issue Jul 24, 2017 · 89 comments · Fixed by #7262
Closed

--build-optimizer errors "Cannot read property 'type' of undefined" #7110

dherges opened this issue Jul 24, 2017 · 89 comments · Fixed by #7262
Labels
effort2: medium (days) freq3: high P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken type: bug/fix

Comments

@dherges
Copy link

dherges commented Jul 24, 2017

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.1
rxjs@^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-optimizer

The 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.ts

Desired 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.

@dherges
Copy link
Author

dherges commented 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
Copy link

rtm commented Jul 27, 2017

I had a similar problem and solved it by replacing import { Observable } from 'rxjs/Rx'; with import { Observable } from 'rxjs/Observable';.

@dherges
Copy link
Author

dherges commented Jul 27, 2017

@rtm Yep, thanks! That's the cause!

@filipesilva Here's the repro: dherges/ng-cli-build-optimizer-issue7110@4a19a56

@Hanfrey FYI ... Fehler erkannt, Fehler gebannt! 🐎

@filipesilva
Copy link
Contributor

This shouldn't happen, and I think it's the same as angular/devkit#51. Will investigate.

@filipesilva filipesilva self-assigned this Jul 28, 2017
@filipesilva filipesilva added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful effort2: medium (days) type: bug/fix freq3: high severity3: broken feature: build-optimizer labels Jul 28, 2017
@chriszrc
Copy link

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
Copy link

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:

ERROR in ./node_modules/rxjs/observable/BoundCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
    at Object.getEffectiveTypeAnnotationNode (C:\dev\my-app\node_modules\typescript\lib\typescript.js:9341:17)
    at assignContextualParameterTypes (C:\dev\my-app\node_modules\typescript\lib\typescript.js:41652:25)
    at checkFunctionExpressionOrObjectLiteralMethod (C:\dev\my-app\node_modules\typescript\lib\typescript.js:41948:29)
    at checkExpressionWorker (C:\dev\my-app\node_modules\typescript\lib\typescript.js:42959:28)
    at checkExpression (C:\dev\my-app\node_modules\typescript\lib\typescript.js:42898:42)
    at checkExpressionCached (C:\dev\my-app\node_modules\typescript\lib\typescript.js:42779:38)
    at checkReturnStatement (C:\dev\my-app\node_modules\typescript\lib\typescript.js:45418:54)
    at checkSourceElement (C:\dev\my-app\node_modules\typescript\lib\typescript.js:46763:28)
    at Object.forEach (C:\dev\my-app\node_modules\typescript\lib\typescript.js:1506:30)
    at checkBlock (C:\dev\my-app\node_modules\typescript\lib\typescript.js:44563:16)
    at checkSourceElement (C:\dev\my-app\node_modules\typescript\lib\typescript.js:46742:28)
    at checkFunctionExpressionOrObjectLiteralMethodDeferred (C:\dev\my-app\node_modules\typescript\lib\typescript.js:41990:21)
    at checkDeferredNodes (C:\dev\my-app\node_modules\typescript\lib\typescript.js:46828:25)
    at checkSourceFileWorker (C:\dev\my-app\node_modules\typescript\lib\typescript.js:46863:17)
    at checkSourceFile (C:\dev\my-app\node_modules\typescript\lib\typescript.js:46842:13)
    at Object.forEach (C:\dev\my-app\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/ng2-adal/services/adal.service.js
 @ ./src/$$_gendir/app/app.module.ngfactory.ts
 @ ./src/main.ts
 @ multi ./src/main.ts

@bjornharvold
Copy link

I'm getting the same error when building and using a third party dependency ng2-responsive.

ERROR in ./node_modules/rxjs/observable/BoundNodeCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
    at Object.getEffectiveTypeAnnotationNode (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:9341:17)
    at assignContextualParameterTypes (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:41652:25)
    at checkFunctionExpressionOrObjectLiteralMethod (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:41948:29)
    at checkExpressionWorker (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:42959:28)
    at checkExpression (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:42898:42)
    at checkExpressionCached (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:42779:38)
    at checkReturnStatement (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:45418:54)
    at checkSourceElement (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:46763:28)
    at Object.forEach (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:1506:30)
    at checkBlock (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:44563:16)
    at checkSourceElement (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:46742:28)
    at checkFunctionExpressionOrObjectLiteralMethodDeferred (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:41990:21)
    at checkDeferredNodes (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:46828:25)
    at checkSourceFileWorker (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:46863:17)
    at checkSourceFile (/Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/typescript/lib/typescript.js:46842:13)
    at Object.forEach (/Users/crash/git/traveliko/traveliko-spa-frontend/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
 @ ./node_modules/ng2-responsive/config/config.js
 @ ./src/$$_gendir/app/app.module.ngfactory.ts
 @ ./src/main.ts

@ multi ./src/main.ts

@filipesilva
Copy link
Contributor

@bjornharvold are you using the latest version of the CLI? In this case it's 1.3.0 final.

@bjornharvold
Copy link

Hi @filipesilva! Yes, that is correct.. Upgraded to 1.3.0 final today and tried the new optimize flag for the first time.

@olaf89
Copy link

olaf89 commented Aug 10, 2017

I have the same issue, version 1.3.0

@Martin-Luft
Copy link

Please reopen this issue @hansl

I habe the same issue with Angular CLI 1.3.0 and Angular 4.3.4 :(

ERROR in ./node_modules/rxjs/observable/BoundCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined

@jinder
Copy link

jinder commented Aug 11, 2017

Also seeing this same issue in 1.3.0. Please re-open.

@sikolio
Copy link

sikolio commented Aug 11, 2017

Same issue here :)

@nmorenor
Copy link

+1
Same issue here ;)

@born2net
Copy link

same issue here, had to update to TS 2.6...

@creativec0de
Copy link

broken for me also!
any fix that does now require to change the typescript version?

@filipesilva
Copy link
Contributor

I'd like to take a look at this issue again but would really like a reproduction from someone that's suffering from this problem on TS 2.4.x, preferably with third party libs as well (as @tstrohecker mentioned in #7110 (comment)).

I understand you all are running into this on your real projects and feel like you can't find the time to do a repro. But over 24 days since I last asked for a repro there were a total of 25 comments on this issue and not a single one offered a reproduction.

You might think the way to reproduce this is really obvious and all the information is in the issue already, but that's because you are running into it and you know what to look for. I'm not running into the issue myself. So anything less than a repro I can follow is just me grasping at straws and trying to fix what I imagine is the problem, instead of what the problem you're actually facing is.

Ideally a repro for this issue would include:

  • a repository that I can clone
  • that's using ts 2.4.x
  • that shows the error when including a third party lib and running ng build --prod
  • the error would go away after updating typescript

@tstrohecker
Copy link

I can no longer reproduce it. I believe it was coming from a dependency on primeng , as well as my local changes. I did not realize importing rxjs/Rxjs had been blacklisted because my tslint file from a cli initialize was old. I was made aware by someone else on my team that it was blacklisted since their project was just initialized, so I replaced all instances. As far as the third party dependency, patched I guess ?

@avadhootha
Copy link

Here you go. I had a similar issue in my project while using ng2-tree of version 2.0.0-rc.2. Up on searching about it, landed up on this page.
Error:

ERROR in ./node_modules/rxjs/_esm5/observable/BoundCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
    at Object.getEffectiveTypeAnnotationNode (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:9341:17)
    at assignContextualParameterTypes (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:41652:25)
    at checkFunctionExpressionOrObjectLiteralMethod (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:41948:29)
    at checkExpressionWorker (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:42959:28)
    at checkExpression (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:42898:42)
    at checkExpressionCached (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:42779:38)
    at checkReturnStatement (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:45418:54)
    at checkSourceElement (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:46763:28)
    at Object.forEach (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:1506:30)
    at checkBlock (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:44563:16)
    at checkSourceElement (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:46742:28)
    at checkFunctionExpressionOrObjectLiteralMethodDeferred (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:41990:21)
    at checkDeferredNodes (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:46828:25)
    at checkSourceFileWorker (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:46863:17)
    at checkSourceFile (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:46842:13)
    at Object.forEach (/home/avadhoothaa/Downloads/cli-quickstart/node_modules/typescript/lib/typescript.js:1506:30)
 @ ./node_modules/rxjs/_esm5/observable/bindCallback.js 2:0-68
 @ ./node_modules/rxjs/_esm5/add/observable/bindCallback.js
 @ ./node_modules/rxjs/_esm5/Rx.js
 @ ./node_modules/ng2-tree/src/tree.service.js
 @ ./src/app/app.module.ngfactory.js
 @ ./src/main.ts
 @ multi ./src/main.ts

I tried to reproduce this same issue with cli-quickstart

  1. I downloaded the cli-quickstart from here
  2. Tried to do ng build --prod --build-optimizer which completed without any errors.
  3. Added ng2-tree to package.json with version "^2.0.0-rc.2".
  4. Added TreeModule to app.module.ts and imported it from ng2-tree
  5. Now tried to do a ng build --prod --build-optimizer which threw the above error.

Tried with typescript version "^2.6.0" after removing @angular/compiler-cli (@angular/compiler-cli@5.0.3 requires typescript@'>=2.4.2 <2.5.0') from the package.json . ng build --prod --build-optimizer works without any issues.

@filipesilva
Copy link
Contributor

@avadhootha thank you, using your repro I can verify the problem. Using ng build --prod --build-optimizer will fail with the following message:

kamik@T460p MINGW64 /d/sandbox/master-project (master)
$ ng build --prod --build-optimizer
Your global Angular CLI version (1.6.0-rc.0) is greater than your local
version (1.5.3). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
Date: 2017-11-24T16:32:02.180Z
Hash: c5cf2258c685c502e97e
Time: 23112ms
chunk {0} polyfills.ad37cd45a71cb38eee76.bundle.js (polyfills) 61.1 kB [initial] [rendered]
chunk {1} main.1419c5c2f716aaab2603.bundle.js (main) 415 kB [initial] [rendered]
chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 0 bytes [initial] [rendered]
chunk {3} inline.b16e6b2baee13a0fc20a.bundle.js (inline) 1.45 kB [entry] [rendered]

ERROR in ./node_modules/rxjs/_esm5/observable/BoundCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
    at Object.getEffectiveTypeAnnotationNode (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:9341:18)
    at assignContextualParameterTypes (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:41652:25)
    at checkFunctionExpressionOrObjectLiteralMethod (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:41948:29)
    at checkExpressionWorker (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:42959:28)
    at checkExpression (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:42898:42)
    at checkExpressionCached (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:42779:38)
    at checkReturnStatement (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:45418:54)
    at checkSourceElement (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:46763:28)
    at Object.forEach (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:1506:30)
    at checkBlock (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:44563:16)
    at checkSourceElement (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:46742:28)
    at checkFunctionExpressionOrObjectLiteralMethodDeferred (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:41990:21)
    at checkDeferredNodes (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:46828:25)
    at checkSourceFileWorker (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:46863:17)
    at checkSourceFile (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:46842:13)
    at Object.forEach (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:1506:30)
    at getDiagnosticsWorker (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:46924:16)
    at getDiagnostics (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:46892:24)
    at Object.getEmitResolver (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:27162:13)
    at emitWorker (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:69722:69)
    at D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:69687:66
    at runWithCancellationToken (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:69779:24)
    at Object.emit (D:\sandbox\master-project\node_modules\typescript\lib\typescript.js:69687:20)
    at Object.transformJavascript (D:\sandbox\master-project\node_modules\@angular-devkit\build-optimizer\src\helpers\transform-javascript.js:80:13)
    at Object.buildOptimizer (D:\sandbox\master-project\node_modules\@angular-devkit\build-optimizer\src\build-optimizer\build-optimizer.js:92:35)
    at Object.buildOptimizerLoader (D:\sandbox\master-project\node_modules\@angular-devkit\build-optimizer\src\build-optimizer\webpack-loader.js:16:40)
 @ ./node_modules/rxjs/_esm5/observable/bindCallback.js 2:0-68
 @ ./node_modules/rxjs/_esm5/add/observable/bindCallback.js
 @ ./node_modules/rxjs/_esm5/Rx.js
 @ ./node_modules/ng2-tree/src/tree.service.js
 @ ./src/app/app.module.ngfactory.js
 @ ./src/main.ts
 @ multi ./src/main.ts

Using ng build --prod --build-optimizer=false the build will not fail.

My longer stacktrace also mentions Build Optimizer specifically.

Build Optimizer doesn't need to use the same TS version as the CLI so I think we'll just update the version there.

@filipesilva filipesilva assigned clydin and unassigned filipesilva Nov 24, 2017
@celsomtrindade
Copy link

I was running into the same issue, even with all the imports correct.

Upgrading TypeScript from 2.4.2 (default from Angular Cli) to 2.6.1 solved the issue without any other change.

@filipesilva
Copy link
Contributor

angular/devkit#299 should fix this.

@filipesilva
Copy link
Contributor

Fixed by angular/devkit#299, will be out on the next release.

@patocardo
Copy link

patocardo commented 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
Copy link

mbark commented Jan 22, 2018

@patocardo Did you try import { BehaviorSubject } from 'rxjs/BehaviorSubject';? That works fine for me.

@patocardo
Copy link

patocardo commented 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
Copy link

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.

dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
@brobert6
Copy link

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-
Copy link

@jsubiratsgirbau i do not have problems importing Observable but there are problems in RXJS node_mdules in rxjs itself

@mateosantosdev
Copy link

I've solved it installing typescript@2.6.1

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
@clydin clydin removed their assignment Jun 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort2: medium (days) freq3: high P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.