firebase / functions-samples

Collection of sample apps showcasing popular use cases using Cloud Functions for Firebase
https://firebase.google.com/docs/functions
Apache License 2.0
12.07k stars 3.84k forks source link

FireStore import error #480

Closed ghost closed 3 years ago

ghost commented 6 years ago

FireStore is imported automatically like so.

 import * as functions from 'firebase-functions';
 import { QuerySnapshot } from '@google-cloud/firestore';
 const admin = require('firebase-admin');
 admin.initializeApp(functions.config().firebase);

const membersSnapshot: QuerySnapshot = await admin.firestore.doc('team/' + groupId + '/members').get()

But when I deploy the function error says those. What am I missing? Thank you!

node_modules/@google-cloud/firestore/types/firestore.d.ts:28:15 - error TS2300: Duplicate identifier 'DocumentData'.

28 export type DocumentData = {[field: string]: any}; ~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:35:15 - error TS2300: Duplicate identifier 'UpdateData'.

35 export type UpdateData = {[fieldPath: string]: any}; ~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:86:16 - error TS2300: Duplicate identifier 'Firestore'.

86 export class Firestore { ~~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:176:16 - error TS2300: Duplicate identifier 'GeoPoint'.

176 export class GeoPoint { ~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:203:16 - error TS2300: Duplicate identifier 'Transaction'.

203 export class Transaction { ~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:320:16 - error TS2300: Duplicate identifier 'WriteBatch'.

320 export class WriteBatch { ~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:414:14 - error TS2717: Subsequent property declarations must have the same type. Property 'lastUpdateTime' must be of type 'string', but here has type 'Timestamp'.

414 readonly lastUpdateTime?: Timestamp; ~~~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:446:16 - error TS2300: Duplicate identifier 'WriteResult'.

446 export class WriteResult { ~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:469:16 - error TS2300: Duplicate identifier 'DocumentReference'.

469 export class DocumentReference { ~~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:609:16 - error TS2300: Duplicate identifier 'DocumentSnapshot'.

609 export class DocumentSnapshot { ~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:678:16 - error TS2300: Duplicate identifier 'QueryDocumentSnapshot'.

678 export class QueryDocumentSnapshot extends DocumentSnapshot { ~~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:705:15 - error TS2300: Duplicate identifier 'OrderByDirection'.

705 export type OrderByDirection = 'desc' | 'asc'; ~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:711:15 - error TS2300: Duplicate identifier 'WhereFilterOp'.

711 export type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>' | 'array-contains'; ~~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:717:16 - error TS2300: Duplicate identifier 'Query'.

717 export class Query { ~

node_modules/@google-cloud/firestore/types/firestore.d.ts:925:16 - error TS2300: Duplicate identifier 'QuerySnapshot'.

925 export class QuerySnapshot { ~~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:977:15 - error TS2300: Duplicate identifier 'DocumentChangeType'.

977 export type DocumentChangeType = 'added' | 'removed' | 'modified'; ~~~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:1020:16 - error TS2300: Duplicate identifier 'CollectionReference'.

1020 export class CollectionReference extends Query { ~~~~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:1071:16 - error TS2300: Duplicate identifier 'FieldValue'.

1071 export class FieldValue { ~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:1132:16 - error TS2300: Duplicate identifier 'FieldPath'.

1132 export class FieldPath { ~~~~~

node_modules/@google-cloud/firestore/types/firestore.d.ts:1243:12 - error TS2300: Duplicate identifier 'FirebaseFirestore'.

1243 export = FirebaseFirestore; ~~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:28:15 - error TS2300: Duplicate identifier 'DocumentData'.

28 export type DocumentData = {[field: string]: any}; ~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:35:15 - error TS2300: Duplicate identifier 'UpdateData'.

35 export type UpdateData = {[fieldPath: string]: any}; ~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:46:16 - error TS2300: Duplicate identifier 'Firestore'.

46 export class Firestore { ~~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:122:16 - error TS2300: Duplicate identifier 'GeoPoint'.

122 export class GeoPoint { ~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:149:16 - error TS2300: Duplicate identifier 'Transaction'.

149 export class Transaction { ~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:266:16 - error TS2300: Duplicate identifier 'WriteBatch'.

266 export class WriteBatch { ~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:393:16 - error TS2300: Duplicate identifier 'WriteResult'.

393 export class WriteResult { ~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:417:16 - error TS2300: Duplicate identifier 'DocumentReference'.

417 export class DocumentReference { ~~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:557:16 - error TS2300: Duplicate identifier 'DocumentSnapshot'.

557 export class DocumentSnapshot { ~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:626:16 - error TS2300: Duplicate identifier 'QueryDocumentSnapshot'.

626 export class QueryDocumentSnapshot extends DocumentSnapshot { ~~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:653:15 - error TS2300: Duplicate identifier 'OrderByDirection'.

653 export type OrderByDirection = 'desc' | 'asc'; ~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:659:15 - error TS2300: Duplicate identifier 'WhereFilterOp'.

659 export type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>'; ~~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:665:16 - error TS2300: Duplicate identifier 'Query'.

665 export class Query { ~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:873:16 - error TS2300: Duplicate identifier 'QuerySnapshot'.

873 export class QuerySnapshot { ~~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:925:15 - error TS2300: Duplicate identifier 'DocumentChangeType'.

925 export type DocumentChangeType = 'added' | 'removed' | 'modified'; ~~~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:968:16 - error TS2300: Duplicate identifier 'CollectionReference'.

968 export class CollectionReference extends Query { ~~~~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:1019:16 - error TS2300: Duplicate identifier 'FieldValue'.

1019 export class FieldValue { ~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:1047:16 - error TS2300: Duplicate identifier 'FieldPath'.

1047 export class FieldPath { ~~~~~

node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts:1073:12 - error TS2300: Duplicate identifier 'FirebaseFirestore'.

1073 export = FirebaseFirestore; ~~~~~

jhuleatt commented 3 years ago

firebase-admin imports firestore, so re-importing it via @google-cloud/firestore is confusing TypeScript. Instead, you can access the type via: admin.firestore.QuerySnapshot