Reputation: 8652
When I upgrade from firebase
v7.14.3 to v7.15.1 I get the following build error / typescript error:
TS2339: Property 'firestore' does not exist on type 'FirebaseNamespace'.
I import and use Firestore as following:
import {firebase} from '@firebase/app';
import '@firebase/firestore';
const firestore: firebase.firestore.Firestore = firebase.firestore();
=> firebase.firestore()
is my issue.
I have probably missed the CHANGELOG, any help on how to migrate this appreciated!
Upvotes: 7
Views: 15247
Reputation: 123
For me worked to update the import from
import * as firebase from 'firebase/app'
to
import firebase from 'firebase/compat/app'
Upvotes: 8
Reputation: 1823
For newer versions it's:
import { getFirestore } from 'firebase/firestore';
const config = {
apiKey: ...,
authDomain: ...,
projectId: ...,
storageBucket: ...,
messagingSenderId: ...,
appId: ...
};
const app = initializeApp(config);
export const db = getFirestore(app);
Upvotes: 13
Reputation: 317497
I have always imported Firebase client SDKs in TypeScript like this:
npm install firebase
import * as firebase from 'firebase/app'
import 'firebase/firestore'
const firestore = firebase.firestore()
Upvotes: 6