firebase-admin-node: typescript definitions conflict with v6.0.0 & @google-cloud/storage and @google-cloud/firestore
Hi,
I have a project which uses firebase-admin & @google-cloud/storage and @google-cloud/firestore. After upgrading to firebase-admin v6.0.0 I get following typescript errors:
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, 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.
node_modules/@google-cloud/firestore/types/firestore.d.ts:79:5 - error TS2374: Duplicate string index signature.
79 [key: string]: any; // Accept other properties, such as GRPC settings.
~~~~~~~~~~~~~~~~~~~
node_modules/firebase-admin/lib/index.d.ts:18:9 - error TS2305: Module '"/Users/ovaris/programming/fs-server/node_modules/@google-cloud/storage/build/src/index"' has no exported member 'Bucket'.
18 import {Bucket} from '@google-cloud/storage';
~~~~~~
node_modules/firebase-admin/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, FirebaseFirestore
23 declare namespace FirebaseFirestore {
~~~~~~~
node_modules/@google-cloud/firestore/types/firestore.d.ts:23:1
23 declare namespace FirebaseFirestore {
~~~~~~~
Conflicts are in this file
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 16
- Comments: 28 (2 by maintainers)
I have the same issue here 😃
Actually it seems that culprit seems to be latest
0.17.0
version of@google-cloud/firestore
. Also2.0.3
version of@google-cloud/storage
has broke typings:Having the same issue
@vdiaz1130 This did not seem to help. I’m still getting the same error.
Same issue here. I’m currently sticking with @google-cloud/storage v1.7.0 since an upgrade to v2 breaks with the error that @ovaris is mentioning.
Same problem here:
package versions
node version: v8.12.0
node_modules/firebase-admin/lib/index.d.ts(18,9): error TS2305: Module '"/Users/mstonys/one/one/functions/node_modules/@google-cloud/storage/build/src/index"' has no exported member 'Bucket'. npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! functions@ build:
tsc` npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the functions@ build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR! /Users/one/.npm/_logs/2018-09-26T06_11_51_398Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code2`
@Mikkelet Try using exact versions instead of approximate (
~
or^
) versions, especially if you haven’t upgraded to@google-cloud/firestore@3
.The
firebase-admin
module may not be using semantic versioning conventions, since the minor bump from8.8.0
to8.9.0
depends on a major bump (2.x.x
to3.x.x
) for@google-cloud/firestore
.This has been fixed in the master branch, and included in the next major release. See #437 and #451 for progress.
I know it is not pretty but here is a “temporary” workaround to get your code to compile and ignore the conflict. Inside your
tsconfig.json
add the following:Read more about this option here: https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/release notes/TypeScript 2.0.md#new---skiplibcheck
Isn’t this because firebase admin uses @types/google-cloud__storage:
But the package already has it’s own definitions? https://www.npmjs.com/package/@google-cloud/storage https://github.com/googleapis/nodejs-storage/blob/master/src/index.ts
If I do:
rm -rf node_modules/@types/google-cloud__storage
then it bypasses the error
UPDATE: Looks like a better potential workaround is to use:
UPDATE 2: I got it working this different way
You can read the related threads here: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/28774 https://github.com/googleapis/nodejs-storage/pull/392 https://github.com/googleapis/nodejs-storage/issues/456
Created a PR https://github.com/firebase/firebase-admin-node/pull/368
@lupas Issue still remains, you cannot use
firebase-admin
package together with latest@google-cloud/storage
because of TS identifier conflicts . You are using storage from insidefirebase-admin
which I would not like to do.How are you importing
Storage
?With
I’m getting following error
As a work arround in your /node_modules/firebase-admin/lib/index.d.ts replace:
Line 18 Instead of: import {Bucket} from ‘@google-cloud/storage’;
Use: import {Storage} from ‘@google-cloud/storage’;
AND Line 589
Instead of: bucket(name?: string): Bucket;
Use: bucket(name?: string): Storage;
And where you need to call it use it like this:
const {Storage} = require(‘@google-cloud/storage’); const gcs = new Storage();
It worked for me, im using:
“@google-cloud/storage”: “^2.0.3”, “firebase-admin”: “~5.12.1”, “firebase-functions”: “^2.0.5”