firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

error TS2374: Duplicate index signature for type 'string'

Open nicklbaert opened this issue 2 years ago • 7 comments

[READ] Step 1: Are you in the right place?

Yes

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Github Actions
  • Firebase SDK version: 11.8.0
  • Firebase Product: firestore
  • Node.js version: v18.16.0
  • NPM version: 11.8.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

I'm simply trying to run npm run build whilst using version 11.8.0 of the firebase-admin node package.

Github Actions fails with the following output:

node_modules/@google-cloud/firestore/types/firestore.d.ts(23,1): error TS6200: Definitions of the following identifiers conflict with those in another file: DocumentFieldValue, DocumentData, PartialWithFieldValue, WithFieldValue, UpdateData, Primitive, NestedUpdateFields, ChildUpdateFields, AddPrefixToKeys, UnionToIntersection, Firestore, GeoPoint, Transaction, BulkWriter, BulkWriterError, WriteBatch, SetOptions, WriteResult, DocumentReference, DocumentSnapshot, QueryDocumentSnapshot, OrderByDirection, WhereFilterOp, Query, QuerySnapshot, DocumentChangeType, CollectionReference, CollectionGroup, QueryPartition, AggregateField, AggregateFieldType, AggregateSpecData, AggregateQuery, AggregateQuerySnapshot, FieldValue, FieldPath, Timestamp, BundleBuilder, v1beta1, v1, OK, CANCELLED, UNKNOWN, INVALID_ARGUMENT, DEADLINE_EXCEEDED, NOT_FOUND, ALREADY_EXISTS, PERMISSION_DENIED, RESOURCE_EXHAUSTED, FAILED_PRECONDITION, ABORTED, OUT_OF_RANGE, UNIMPLEMENTED, INTERNAL, UNAVAILABLE, DATA_LOSS, UNAUTHENTICATED, Filter, FirebaseFirestore
node_modules/@google-cloud/firestore/types/firestore.d.ts(302,5): error TS2374: Duplicate index signature for type 'string'.
node_modules/@google-cloud/firestore/types/firestore.d.ts(2085,5): error TS2374: Duplicate index signature for type 'string'.
../../../../node_modules/@google-cloud/firestore/types/firestore.d.ts(23,1): error TS6200: Definitions of the following identifiers conflict with those in another file: DocumentFieldValue, DocumentData, PartialWithFieldValue, WithFieldValue, UpdateData, Primitive, NestedUpdateFields, ChildUpdateFields, AddPrefixToKeys, UnionToIntersection, Firestore, GeoPoint, Transaction, BulkWriter, BulkWriterError, WriteBatch, SetOptions, WriteResult, DocumentReference, DocumentSnapshot, QueryDocumentSnapshot, OrderByDirection, WhereFilterOp, Query, QuerySnapshot, DocumentChangeType, CollectionReference, CollectionGroup, QueryPartition, AggregateField, AggregateFieldType, AggregateSpecData, AggregateQuery, AggregateQuerySnapshot, FieldValue, FieldPath, Timestamp, BundleBuilder, v1beta1, v1, OK, CANCELLED, UNKNOWN, INVALID_ARGUMENT, DEADLINE_EXCEEDED, NOT_FOUND, ALREADY_EXISTS, PERMISSION_DENIED, RESOURCE_EXHAUSTED, FAILED_PRECONDITION, ABORTED, OUT_OF_RANGE, UNIMPLEMENTED, INTERNAL, UNAVAILABLE, DATA_LOSS, UNAUTHENTICATED, Filter, FirebaseFirestore
../../../../node_modules/@google-cloud/firestore/types/firestore.d.ts(302,5): error TS2374: Duplicate index signature for type 'string'.
../../../../node_modules/@google-cloud/firestore/types/firestore.d.ts(2085,5): error TS2374: Duplicate index signature for type 'string'.
npm ERR! Lifecycle script `build` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: ...
npm ERR!   at location: ...
Error: Process completed with exit code 1.

Relevant Code:

package.json:

"dependencies": {
    "firebase-admin": "^11.8.0",
    "firebase-functions": "^4.4.0",
    "pg": "^8.10.0"
  },
"devDependencies": {
    "@types/pg": "^8.6.6",
    "firebase-functions-test": "^3.0.0"
}

nicklbaert avatar May 23 '23 14:05 nicklbaert

Hi @nicklbaert, based on the error message, seems like some functions has been imported from different sources. Could you please double check all the files and make sure the importation are the same?

Meanwhile, there is a similar issue ticket: https://github.com/firebase/firebase-admin-node/issues/734. Adding skipLibCheck in tsconfig might be a workaround.

milaGGL avatar May 23 '23 16:05 milaGGL

Hey @milaGGL, thank you for your time and the quick response. I've double checked everything. The error also occurred seemingly overnight without any relevant changes to our code. Could it maybe be related to the fact that @google-cloud/firestore recently had a new update to version 6.6.0 whilst firebase-admin still uses 6.5.0?

nicklbaert avatar May 23 '23 17:05 nicklbaert

With pleasure. So it was working all fine before, but suddenly started crashing overnight without a change. Have you upgraded any packages in your app?

milaGGL avatar May 23 '23 18:05 milaGGL

@milaGGL We had the same CI running without problems 2 days ago. Since then no packages have been changed. Maybe also worth noting, that the failing command npm run build runs locally without issues. The problem seems to occur only in Github Actions.

nicklbaert avatar May 24 '23 04:05 nicklbaert

I had this same problem. It sent me down tsconfig-hell for 4+ hours trying to figure it out. ChatGPT 4 has no clue wtf is happening either.

This happened to me because I had a repo with 3 folders; /server /common /worker. They all had firebase-admin package installed (same version), and /server and /worker are both importing from /common. I removed firebase-admin as a dependency in /worker and stopped relying on it, and turned /common into its own local package using a yarn workspace monorepo for all 3, and then had both /worker and /server treat /common as a proper npm-dependency rather than just a folder they both import from.

Honestly tsconfig / package.json and all these weird build configurations are just far too complex. 'dev' mode with ts-node and 'prod' mode with node are like two separate conflicting runtime environments that can't agree on how to resolve import paths or dependencies.

PaulFidika avatar Mar 10 '24 20:03 PaulFidika

Hi @PaulFidika, thank you for sharing this issue. Would it be possible to provide a minimal code so that I can reproduce it on my end?

milaGGL avatar Mar 11 '24 16:03 milaGGL