Angularfire: Can't use angular AOT because of angularfire typescript error

Created on 15 Jan 2018  Â·  14Comments  Â·  Source: angular/angularfire

Version info

Angular: 5.0.3

Firebase: 4.8.0

AngularFire: 5.0.0-rc.4

Other (e.g. Ionic/Cordova, Node, browser, operating system):

Ionic Framework 3.9.2
Node v8.9.3

How to reproduce these conditions

Debug output

Steps to set up and reproduce

Generate an ionic project with angularfire & firebase then run ionic cordova build -- prod

I get the following error from AOT compilation:

`typescript error expected 0 arguments but got 2
angularfire.firesotre.index.d.ts ([object Object], ?).

Error: The Angular AoT build failed. See the issues above`

Most helpful comment

@davideast It Only appear with --aot=true --t=production On zone.js I think. But angularfire2 was the only package that I've updated.

image

All 14 comments

We've fixed this issue in the beta release. Can you give it a try by installing npm i angularfire2@next.

@davideast Now when I do a AOT build I get a lot more errors like the following:

typescript: node_modules/angularfire2/firebase.app.module.d.ts, line: 3 Cannot find module '@firebase/app-types'.

typescript: node_modules/angularfire2/firebase.app.module.d.ts, line: 4 Cannot find module '@firebase/auth-types'.

typescript: node_modules/angularfire2/firestore/collection/changes.d.ts, line: 1 Cannot find module '@firebase/firestore-types'.

typescript: node_modules/angularfire2/database/database.d.ts, line: 1 Cannot find module '@firebase/database-types'.

Ok updated to firebase 4.8.2 and it looks like the same error is occuring now:

Warning: Can't resolve all parameters for AngularFirestore in /Users/imac/Documents/projects/test/node_modules/angularfire2/firestore/index.d.ts: ([object Object], ?). This will become an error in Angular v6.x Warning: Can't resolve all parameters for AngularFirestore in /Users/imac/Documents/projects/test/node_modules/angularfire2/firestore/index.d.ts: ([object Object], ?). This will become an error in Angular v6.x [18:38:00] typescript error Expected 0 arguments, but got 2.

Thank you for looking into it.

Ionic 3.19.1
and updated to angularfire2@next

Hi @Joebob12! That message is just a warning, not an error. However, We sent another next release out yesterday. Can you update to that. It contains fixes for the warning you received above.

@davideast I agree in that it is a warning but below the warning it results in a typescript error as follows:

typescript error Expected 0 arguments, but got 2.

Before the warning and the typescript error is ngc started... and then the warning/error. Trying to give more information so we can resolve this issue. I see this version of angularfire in my node_modules: [email protected]

Because the typescript does not finish the compile I do not get a generated ionic application as a result.

EDIT: Diving a little deeper I thought upgrading to firebase 4.9.* would solve the issue because I'm now seeing typings for firestore in my node_modules: @firebase/[email protected] but alas no luck.

Still failing in rc.6.0-next Uncaught TypeError: Cannot read property 'apply' of undefined

@wojtek1150 Can you provide more details? You are the first one to report that error so it would be helpful to see more code a link to repro

@davideast It Only appear with --aot=true --t=production On zone.js I think. But angularfire2 was the only package that I've updated.

image

have the same issue and 'apply of undefined' runtime error with Ng5 prod build. Might this be related to rxjs 5.5.x update?

EDIT: Stack trace from Chrome

ERROR TypeError: Cannot read property 'apply' of undefined
at e.project (main.a5691d6331e041879af2.bundle.js:1)
at e._next (main.a5691d6331e041879af2.bundle.js:1)
at e.next (main.a5691d6331e041879af2.bundle.js:1)
at e._next (main.a5691d6331e041879af2.bundle.js:1)
at e.next (main.a5691d6331e041879af2.bundle.js:1)
at e.next (main.a5691d6331e041879af2.bundle.js:1)
at e._next (main.a5691d6331e041879af2.bundle.js:1)
at e.next (main.a5691d6331e041879af2.bundle.js:1)
at n.observe (main.a5691d6331e041879af2.bundle.js:1)
at e.dispatch (main.a5691d6331e041879af2.bundle.js:1)
Rn @ main.a5691d6331e041879af2.bundle.js:1
n.handleError @ main.a5691d6331e041879af2.bundle.js:1
next @ main.a5691d6331e041879af2.bundle.js:1
e.object.o @ main.a5691d6331e041879af2.bundle.js:1
e.__tryOrUnsub @ main.a5691d6331e041879af2.bundle.js:1
e.next @ main.a5691d6331e041879af2.bundle.js:1
e._next @ main.a5691d6331e041879af2.bundle.js:1
e.next @ main.a5691d6331e041879af2.bundle.js:1
e.next @ main.a5691d6331e041879af2.bundle.js:1
e.emit @ main.a5691d6331e041879af2.bundle.js:1
(anonymous) @ main.a5691d6331e041879af2.bundle.js:1
t.invoke @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
e.run @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
n.runOutsideAngular @ main.a5691d6331e041879af2.bundle.js:1
onHandleError @ main.a5691d6331e041879af2.bundle.js:1
t.handleError @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
e.runTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
e.invokeTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
invoke @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
n.args.(anonymous function) @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
setInterval (async)
u @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
t.scheduleTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
onScheduleTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
t.scheduleTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
e.scheduleTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
e.scheduleMacroTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
v @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
(anonymous) @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
F.i.(anonymous function) @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
e.requestAsyncId @ main.a5691d6331e041879af2.bundle.js:1
e.schedule @ main.a5691d6331e041879af2.bundle.js:1
n.schedule @ main.a5691d6331e041879af2.bundle.js:1
e._schedule @ main.a5691d6331e041879af2.bundle.js:1
e.scheduleNotification @ main.a5691d6331e041879af2.bundle.js:1
e._next @ main.a5691d6331e041879af2.bundle.js:1
e.next @ main.a5691d6331e041879af2.bundle.js:1
e._next @ main.a5691d6331e041879af2.bundle.js:1
e.next @ main.a5691d6331e041879af2.bundle.js:1
(anonymous) @ main.a5691d6331e041879af2.bundle.js:1
s @ main.a5691d6331e041879af2.bundle.js:1
(anonymous) @ main.a5691d6331e041879af2.bundle.js:1
F1yO.e.exceptionGuard @ main.a5691d6331e041879af2.bundle.js:1
n.raise @ main.a5691d6331e041879af2.bundle.js:1
n.raiseQueuedEventsMatchingPredicate_ @ main.a5691d6331e041879af2.bundle.js:1
n.raiseEventsForChangedPath @ main.a5691d6331e041879af2.bundle.js:1
n.onDataUpdate_ @ main.a5691d6331e041879af2.bundle.js:1
e.onDataPush_ @ main.a5691d6331e041879af2.bundle.js:1
e.onDataMessage_ @ main.a5691d6331e041879af2.bundle.js:1
n.onDataMessage_ @ main.a5691d6331e041879af2.bundle.js:1
n.onPrimaryMessageReceived_ @ main.a5691d6331e041879af2.bundle.js:1
(anonymous) @ main.a5691d6331e041879af2.bundle.js:1
e.appendFrame_ @ main.a5691d6331e041879af2.bundle.js:1
e.handleIncomingFrame @ main.a5691d6331e041879af2.bundle.js:1
mySock.onmessage @ main.a5691d6331e041879af2.bundle.js:1
E @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
t.invokeTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
onInvokeTask @ main.a5691d6331e041879af2.bundle.js:1
t.invokeTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
e.runTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
e.invokeTask @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
m @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1
b @ polyfills.4c358bc5acb2f9ea7d92.bundle.js:1

Looks like for me the exception occurs when chaining subscribe to valueChanges() -

this.af.list(dbRoot).valueChanges().take(1) .subscribe((items:Items[]) => {});

Here's my env -
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ â–³ \ | '_ \ / _| | | | |/ _ | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ __| |_|__, |__,_|_|__,_|_| ____|_____|___|
|___/

Angular CLI: 1.6.6
Node: 9.2.1
OS: darwin x64
Angular: 5.2.2
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker

@angular/cdk: 5.1.0
@angular/cli: 1.6.6
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/material: 5.1.0
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@schematics/angular: 0.1.17
typescript: 2.6.1
webpack: 3.10.0

Hope it helps narrow it down.

Here's the stack trace on Firefox -

ERROR
TypeError: c.a.merge is undefined
Stack trace:
fn/http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:1264029
5jKg/r_next@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:196719
E9/g/anext@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:337863
E9/g/a_next@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:338180
E9/g/anext@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:337863
TO51/cnext@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:1002570
E9/g/a_next@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:338180
E9/g/anext@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:337863
PAZ8/oobserve@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:646694
YRqN/rdispatch@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:1191227
GTlS/u_execute@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:391812
Gcw1/oexecute@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:393077
wclm/iflush@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:7661179
Gcw1/oschedule@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:392950
wclm/oschedule@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:7660794
cDNt/onhttp://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:1262010
eFQL/invoke@http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:44995
onInvoke@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:508467
eFQL/invoke@http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:44922
eFQL/run@http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:40149
cDNt/onschedule@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:1261978
YRqN/rscheduleMessage@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:1191334
YRqN/r_next@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:1191439
E9/g/anext@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:337863
PAZ8/oobserve@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:646694
Bu8b/sdispatch@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:308164
GTlS/u_execute@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:391812
GTlS/uexecute@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:391628
wclm/iflush@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:7661179
eFQL/invokeTask@http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:45670
onInvokeTask@http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:508379
eFQL/invokeTask@http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:45583
eFQL/runTask@http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:40840
eFQL/invokeTask@http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:46784
e/this.invoke<@http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:46666
c/n.args[0]@http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:62984
main.2f4777376cf27800c1e6.bundle.js:1:491389
Rn
http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:491389
LMZF/ http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:491595
next
http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:514235
LMZF/ http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:507122
E9/g/s http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:339848
E9/g/s http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:339123
E9/g/a http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:338180
E9/g/a http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:337863
TO51/c http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:1002570
LMZF/ http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:506881
onHandleError/<
http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:508777
eFQL/ http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:44995
eFQL/ http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:40149
LMZF/ http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:509486
onHandleError
http://localhost:8080/main.2f4777376cf27800c1e6.bundle.js:1:508739
eFQL/ http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:45075
eFQL/ http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:40894
eFQL/ http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:46784
e/this.invoke<
http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:46666
c/n.args[0]
http://localhost:8080/polyfills.75d6e1366e9ec579513e.bundle.js:1:62984

Looking at the trace and source code, the exception seems to be thrown in database.umd.js, line 68 -

function listChanges(ref, events) {
return fromRef(ref, 'value', 'once').switchMap(function (snapshotAction) {
var childEvent$ = [rxjs_Observable.Observable.of(snapshotAction)];
events.forEach(function (event) { return childEvent$.push(fromRef(ref, event)); });
## return rxjs_Observable.Observable.merge.apply(rxjs_Observable.Observable, childEvent$).scan(buildView, []);
})
.distinctUntilChanged();
}

If this still is an issue please open a fresh issue with a StackBlitz, we've released a lot since then + are starting the RXJS 6 migration.

@wojtek1150 hello, were you able to find a solution ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jnupeter picture jnupeter  Â·  3Comments

Maistho picture Maistho  Â·  3Comments

avanderbergh picture avanderbergh  Â·  3Comments

mypark picture mypark  Â·  3Comments

martinyoussef picture martinyoussef  Â·  3Comments