geofirestore-js
geofirestore-js copied to clipboard
Typescript errors when trying to deploy function
Environment
Operating System version: Windows 11 Browser version: Google chrome 109.0.5414.75 Firebase library: Firebase and version: 10.2.0 GeoFirestore version: 5.2.0
Getting error in firebase deploy cmd when i trying to deploy the function getting error i tried by deleting node_modules folder and then npm install but it's not resolved.
` i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run build
build tsc
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, BulkWriter, BulkWriterError, WriteBatch, SetOptions, WriteResult, DocumentReference, DocumentSnapshot, QueryDocumentSnapshot, OrderByDirection, WhereFilterOp, Query, QuerySnapshot, DocumentChangeType, CollectionReference, CollectionGroup, QueryPartition, 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, FirebaseFirestore
23 declare namespace FirebaseFirestore {
node_modules/geofirestore-core/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:174:5 - error TS2374: Duplicate index signature for type 'string'.
174 [key: string]: any; // Accept other properties, such as GRPC settings.
~~~~~~~~~~~~~~~~~~~
node_modules/geofirestore-core/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, BulkWriter, BulkWriterError, WriteBatch, SetOptions, WriteResult, DocumentReference, DocumentSnapshot, QueryDocumentSnapshot, OrderByDirection, WhereFilterOp, Query, QuerySnapshot, DocumentChangeType, CollectionReference, CollectionGroup, QueryPartition, 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, 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.
node_modules/geofirestore-core/node_modules/@google-cloud/firestore/types/firestore.d.ts:71:25 - error TS2315: Type 'UpdateData' is not generic.
71 ? {[K in keyof T]?: UpdateData<T[K]> | FieldValue} & NestedUpdateFields<T> ~~~~~~~~~~~~~~~~
node_modules/geofirestore-core/node_modules/@google-cloud/firestore/types/firestore.d.ts:104:28 - error TS2315: Type 'UpdateData' is not generic.
104 AddPrefixToKeys<K, UpdateData<V>> ~~~~~~~~~~~~~
node_modules/geofirestore-core/node_modules/@google-cloud/firestore/types/firestore.d.ts:282:5 - error TS2374: Duplicate index signature for type 'string'.
282 [key: string]: any; // Accept other properties, such as GRPC settings. ~~~~~~~~~~~~~~~~~~~
node_modules/geofirestore-core/node_modules/@google-cloud/firestore/types/firestore.d.ts:655:13 - error TS2315: Type 'UpdateData' is not generic.
655 data: UpdateData<T>, ~~~~~~~~~~~~~
node_modules/geofirestore-core/node_modules/@google-cloud/firestore/types/firestore.d.ts:806:13 - error TS2315: Type 'UpdateData' is not generic.
806 data: UpdateData<T>, ~~~~~~~~~~~~~
node_modules/geofirestore-core/node_modules/@google-cloud/firestore/types/firestore.d.ts:1029:13 - error TS2315: Type 'UpdateData' is not generic.
1029 data: UpdateData<T>, ~~~~~~~~~~~~~
node_modules/geofirestore-core/node_modules/@google-cloud/firestore/types/firestore.d.ts:1254:13 - error TS2315: Type 'UpdateData' is not generic.
1254 data: UpdateData<T>, ~~~~~~~~~~~~~
Found 10 errors in 2 files.
Errors Files 2 node_modules/@google-cloud/firestore/types/firestore.d.ts:23 8 node_modules/geofirestore-core/node_modules/@google-cloud/firestore/types/firestore.d.ts:23
Error: functions predeploy error: Command terminated with non-zero exit code 2`
package.json
"engines": { "node": "16" }, "main": "lib/index.js", "dependencies": { "express": "^4.18.2", "firebase-admin": "^10.2.0", "firebase-functions": "^3.21.0", "geofirestore": "^5.2.0", "moment-timezone": "^0.5.40", "ngeohash": "^0.6.3", "uuid": "^9.0.0" }, "devDependencies": { "typescript": "^4.6.4" },
My Code
import { Request, Response, NextFunction } from "express"; import * as admin from "firebase-admin"; import * as geofirestore from "geofirestore"; //let GeoFire = require('geofire'); var geohash = require("ngeohash"); export async function filterBusinessByDistance(req: Request, res: Response) { try { const uid = res.locals.uid;
const latitude = 28.431399;
const longitude = 77.50627;
const firestore = admin.firestore();
const Geofirestore = geofirestore.initializeApp(firestore);
const geocollection = Geofirestore.collection("business");
const queryCollection = geocollection.near({
center: new admin.firestore.GeoPoint(latitude, longitude),
radius: 20,
limit: 35,
});
let businessNearbyRef = await queryCollection.get();
res.status(200).json({
status: "1",
message: "success",
payload: businessNearbyRef,
});
} catch (error) { console.log(error); res.status(400).json({ status: "0", message: error, payload: null, }); } }