firebase / firebase-admin-node

Firebase Admin Node.js SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
1.63k stars 371 forks source link

[Firestore] Type definitions are in conflict with @google-cloud/firestore v 3.0.0 #734

Closed arpit closed 4 years ago

arpit commented 4 years ago

3.0.0 was only released yesterday, so not unexpected but still

node_modules/@google-cloud/firestore/types/firestore.d.ts:23:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: DocumentData, UpdateData, Firestore, GeoPoint, Transaction, WriteBatch, WriteResult, DocumentReference, DocumentSnapshot, QueryDocumentSnapshot, OrderByDirection, WhereFilterOp, Query, QuerySnapshot, DocumentChangeType, CollectionReference, FieldValue, FieldPath, Timestamp, v1beta1, v1, FirebaseFirestore

23 declare namespace FirebaseFirestore {
   ~~~~~~~

  node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:23:1
    23 declare namespace FirebaseFirestore {
       ~~~~~~~
    Conflicts are in this file.
google-oss-bot commented 4 years ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

schmidt-sebastian commented 4 years ago

@arpit Thanks for the report. You seem to be using two different versions of Firestore (one from node_modules/@google-cloud/firestore and one from node_modules/firebase-admin/node_modules/@google-cloud/firestore). As shown in your errors, this breaks the TypeScript compile.

We haven't yet updated Firebase Admin to include Firestore 3.0. If you want to avoid this problem, you can install Firebase Admin from this branch:

"dependencies": {
   "firebase-admin": "git+https://github.com/firebase/firebase-admin-node.git#firestore-30"
}
manwithsteelnerves commented 4 years ago

@schmidt-sebastian We are currently using firebase-admin 8.10.0 and facing this issue. Does it mean firestore 3.0 is not yet into the admin module?

schmidt-sebastian commented 4 years ago

Firebase Admin Node depends on 3.x Firestore: https://github.com/firebase/firebase-admin-node/blob/master/package.json#L64

manwithsteelnerves commented 4 years ago

So any reason why its still showing the confict?

schmidt-sebastian commented 4 years ago

I have seen cases like this before when two version of Firestore were included via NPM's dependency resolution. This doesn't necessarily have to be related to Firebase Admin.

manwithsteelnerves commented 4 years ago

Ok, Here is our scenario. We installed both firebase-admin as well as @google-cloud/firestore in our project. The reason why we had @google-cloud/firestore is

  1. To connect to local firestore emulator during our tests. (emulators:exec is buggy to use)
  2. We need to connect to a different firestore project from the current project.

What we have observed is nested node-modules folder with in the node-modules/firebase-admin has @google-cloud/firestore types too leading to the issue. We see it a general use case too as its quite common to use @google-cloud/firestore package.

This issue didn't happen earlier but only on upgrading to latest firebase-admin.

To solve it temporarily, we just deleted the types file listed in firebase-admin to avoid the conflicting error. But we see it would be great if there is a right solution.

google-cloud-firestore firebase-admin

schmidt-sebastian commented 4 years ago

You should be able to use @google-cloud/firestore and firebase-admin together if they point to the same version. NPM will not duplicate the package if the version can be shared.

asithade commented 4 years ago

Seeing this same error now too.

Currently have the following packages:

    "firebase-admin": "^8.12.1",
    "@google-cloud/firestore": "^3.8.0",

Adding skipLibCheck in tsconfig to true allows me to continue, but ideally we don't want to do that.

dobromyslov commented 4 years ago

@asithade thank you for the workaround.

svenjacobs commented 3 years ago

I'm facing the same issue with

"@google-cloud/pubsub": "^2.14.0",
"firebase-admin": "^9.9.0",

Is there any fix / workaround except skipLibCheck?