-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript errors when trying to deploy function #238
Comments
I'm also getting this problem. This is serious, the library is not being maintained and updated. No work around as far as I know. |
switch to geofire-common . supported by google. since geofirestore stores geohash, just point geofire-common to it. so there is no need to make changes to documents stored in firebase. import * as geofire from 'geofire-common';
/**
* Given a firebase Query, add a check to get the range bound entries.
* Reuse lat, lng attributes defined by now deprecated geofirestore
* @param userCoords geofire.GeoPoint
* @param _radius in metres
* @return array of promises of of QueryDocumentSnapshots that match the distance specified
*/
getGeoQuery(
geoCollection: FirebaseFirestore.CollectionReference,
userCoords: geofire.Geopoint,
_radius: number): Observable<FirebaseFirestore.QueryDocumentSnapshot[]> {
const bounds = geofire.geohashQueryBounds(userCoords, _radius);
const promises = <Promise<FirebaseFirestore.QuerySnapshot>[]>[];
for (const b of bounds) {
const q = geoCollection.orderBy('g.geohash').startAt(b[0]).endAt(b[1]);
promises.push(q.get());
}
return from(Promise.all(promises).then((snapshots) => {
const matchingDocs = [];
for (const snap of snapshots) {
for (const doc of snap.docs) {
const coords = <GeoPoint>doc.get('geoCoords');
const distInKm = geofire.distanceBetween([ coords.latitude, coords.longitude ], userCoords);
const distInM = distInKm * 1000;
if (distInM < _radius) {
matchingDocs.push(doc);
}
}
}
return matchingDocs;
}));
} |
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
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
~~~~~~~~~~~~~~~~
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>
~~~~~~~~~~~~~
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,
~~~~~~~~~~~~~
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,
~~~~~~~~~~~~~
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,
~~~~~~~~~~~~~
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,
~~~~~~~~~~~~~
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;
} catch (error) {
console.log(error);
res.status(400).json({
status: "0",
message: error,
payload: null,
});
}
}
The text was updated successfully, but these errors were encountered: