Property 'firestore' does not exist on type 'FirebaseNamespace' with Firebase v7.15.1

Viewed 8928

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!

2 Answers

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()

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);
Related