0

I am trying to use the Firebase increment function and it's giving me an error. I am using Ionic 5.2.7.

Here is my import statement for firebase

import { firebase } from '@firebase/app';

(if I try to import from firebase like - import { firebase } from 'firebase/app'; - the import fails, so I can't do that.)

My error is on the increment statement:

const itemsCount = firebase.firestore.FieldValue.increment(1);

The error is: "Property 'firestore' does not exist on type 'FirebaseNamespace'."

Bluemax86
  • 5
  • 2
  • Did you also `import '@firebase/firestore`? In fact, as far as I can see you should import `import firebase from 'firebase/app'; import 'firebase/firestore'` so without the `@` prefix. – Frank van Puffelen Jun 03 '20 at 14:29
  • Have you also checked similar questions of the community? [1] https://stackoverflow.com/questions/61189443/firebase-firestore-increment-fieldvalue-does-not-increment [2] https://stackoverflow.com/questions/50499829/ionic-increment-firestore-value [3] https://stackoverflow.com/questions/54543067/firestore-increment-fieldvalue – Antonio Ramirez Jun 04 '20 at 15:23
  • I finally found the solution. I needed to change the import statement as follows: import * as firebase from 'firebase/app'; I am still getting used to the different syntax on import statements. Thanks all for the feedback – Bluemax86 Jun 04 '20 at 15:54
  • I have just re-posted your comment as a community week answer. This will not give me reputation; just to give it more visibility in case has the same issue. – Antonio Ramirez Jun 05 '20 at 20:20

1 Answers1

0

I finally found the solution.

I needed to change the import statement as follows:

 import * as firebase from 'firebase/app'
Antonio Ramirez
  • 943
  • 6
  • 15