Angularfire: AngularFire is not compatible with Firebase JS SDK v8

Created on 27 Oct 2020  路  16Comments  路  Source: angular/angularfire

Version info

Angular: v10.2.0

Firebase: v8.0.0

AngularFire: v6.0.3

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

Debug output

ERROR in node_modules/@angular/fire/auth/auth.d.ts:4:10 - error TS2614: Module '"../../../firebase"' has no exported member 'User'. Did you mean to use 'import User from "../../../firebase"' instead?
4 import { User, auth } from 'firebase/app';
           ~~~~
node_modules/@angular/fire/auth/auth.d.ts:4:16 - error TS2614: Module '"../../../firebase"' has no exported member 'auth'. Did you mean to use 'import auth from "../../../firebase"' instead?
4 import { User, auth } from 'firebase/app';

Expected behavior

There should be no errors.

Most helpful comment

@jamesdaniels Sorry for the absence. I tested 6.0.4 with firebase@7 and it does not work. In firebase@8 it does work though.

Here's my analysis.

In firebase@7, the firebase is export as such:

export = firebase;

So, to be able to use import firebase from 'firebase'; in AngularFire's codebase, the user needs to have allowSyntheticDefaultImports set as true in their tsconfig.json.

But in 6.0.4 type definition, there is one line that is problematic. Here:

https://unpkg.com/browse/@angular/fire@6.0.4/storage/observable/fromTask.d.ts

The import("firebase").default.storage.UploadTaskSnapshot does not play very well with "allowSyntheticDefaultImports": true. Hence, there is this error while building a project with 6.0.4 and firebase@7:

ERROR in node_modules/@angular/fire/storage/observable/fromTask.d.ts:3:83 - error TS2694: Namespace 'firebase' has no exported member 'default'.
3 export declare function fromTask(task: UploadTask): Observable<import("firebase").default.storage.UploadTaskSnapshot>;

Please take a look. I'm not sure why the generated .d.ts is using the import() type syntax, though.

All 16 comments

Give 6.0.4-canary.9a26fbe a spin, I'll be releasing 6.0.4 final shortly.

Releasing 6.0.4 with support for v8 later today.

@jamesdaniels Sorry for the absence. I tested 6.0.4 with firebase@7 and it does not work. In firebase@8 it does work though.

Here's my analysis.

In firebase@7, the firebase is export as such:

export = firebase;

So, to be able to use import firebase from 'firebase'; in AngularFire's codebase, the user needs to have allowSyntheticDefaultImports set as true in their tsconfig.json.

But in 6.0.4 type definition, there is one line that is problematic. Here:

https://unpkg.com/browse/@angular/fire@6.0.4/storage/observable/fromTask.d.ts

The import("firebase").default.storage.UploadTaskSnapshot does not play very well with "allowSyntheticDefaultImports": true. Hence, there is this error while building a project with 6.0.4 and firebase@7:

ERROR in node_modules/@angular/fire/storage/observable/fromTask.d.ts:3:83 - error TS2694: Namespace 'firebase' has no exported member 'default'.
3 export declare function fromTask(task: UploadTask): Observable<import("firebase").default.storage.UploadTaskSnapshot>;

Please take a look. I'm not sure why the generated .d.ts is using the import() type syntax, though.

I am still having the same problem. Angular version 11.0.2 and AngularFire version 6.1.1

image

image

I am still having the same problem. Angular version 11.0.2 and AngularFire version 6.1.1

image

image

Drop angularfire2, that's no longer maintained and looks like it's wrapping an old version of @angular/fire

Yeah. It works now, thanks!

@dusanradojcic00 how'd you get it working??. I'm using angularfire v6.1.2 and i'm still getting those errors

@wizjamin remove angularfire2, that's what worked for me. Check all dependencies and imports inside NgModule.

@jamesdaniels Sorry for the absence. I tested 6.0.4 with firebase@7 and it does not work. In firebase@8 it does work though.

Here's my analysis.

In firebase@7, the firebase is export as such:

export = firebase;

So, to be able to use import firebase from 'firebase'; in AngularFire's codebase, the user needs to have allowSyntheticDefaultImports set as true in their tsconfig.json.

But in 6.0.4 type definition, there is one line that is problematic. Here:

https://unpkg.com/browse/@angular/fire@6.0.4/storage/observable/fromTask.d.ts

The import("firebase").default.storage.UploadTaskSnapshot does not play very well with "allowSyntheticDefaultImports": true. Hence, there is this error while building a project with 6.0.4 and firebase@7:

ERROR in node_modules/@angular/fire/storage/observable/fromTask.d.ts:3:83 - error TS2694: Namespace 'firebase' has no exported member 'default'.
3 export declare function fromTask(task: UploadTask): Observable<import("firebase").default.storage.UploadTaskSnapshot>;

Please take a look. I'm not sure why the generated .d.ts is using the import() type syntax, though.

Fixed in 6.1.4 by #2703.

I still can't get auth and User by importing firebase/app. It just says it doesn't have an exported member User and auth.

firebase version: 8.2.0
AngularFire version: 6.1.4
Angular version: 11.0.5

@Reprevise same here! =(

I still can't get auth and User by importing firebase/app. It just says it doesn't have an exported member User and auth.

firebase version: 8.2.0
AngularFire version: 6.1.4
Angular version: 11.0.5

same issue. auth has apparently been removed

@Reprevise @eduardovpessoa @shadowboxingskills

You need to know now from version 8 you can import just the services you use:

// This import loads the firebase namespace along with all its type information.
import firebase from 'firebase/app';

// These imports load individual services into the firebase namespace.
import 'firebase/auth';
import 'firebase/database';

You can read more about here

You have to use the full form firebase.auth.User in v8, can't shorthand it as auth.User

I have :

import firebase from 'firebase/app';
import 'firebase/auth'

I can use firebase.User but not firebase.auth.User ...

Ah yeah, they just changed the API in v8 firebase.User is the same thing auth.User used to be.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aucevica picture aucevica  路  3Comments

StephenFluin picture StephenFluin  路  3Comments

mypark picture mypark  路  3Comments

sharomet picture sharomet  路  3Comments

jteplitz picture jteplitz  路  3Comments