将Firestore依赖项和types导入到node.js

我最近在今年的FirebaseSummit会谈后将我的云function更新到了TypeScript

我所有的代码看起来相当酷,但我有一些问题,试图恢复types的Firestore API,如QuerySnapshotDocumentReference

 async function getEventsMadeByUser(userId: string): Promise<FirebaseFirestore.DocumentSnapshot[]> { const eventsMadeByUserQuery = await instance.collection('PrivateUserData') .doc(userId).collection(EVENTS) .where('interactionUser', '==', userId).get(); return eventsMadeByUserQuery.docs; } 

现在我的IDE(WebStorm)没有获取FirebaseFirestore的types。 这是我的package.json外观:

 { "name": "functions", "description": "Cloud Functions for Firebase", "dependencies": { "firebase-admin": "^5.4.3", "firebase-functions": "^0.7.2" }, "devDependencies": { "@types/express": "^4.0.37", "typescript": "^2.3.2" }, "scripts": { "build": "tsc", "watch": "tsc --watch", "deploy": "tsc && firebase deploy --only functions" }, "main": "build/index.js", "private": true } 

我已经尝试添加@ firebase-firestore ,没有任何东西,它不工作。 有人知道正确的依赖来实现这一目标?

非常感谢

我终于想通了! firebase-admin模块只是一个简单的包装,为您初始化Firestore。 要获得真正的Firestore,请将"@google-cloud/firestore": "^0.9.0"到您的package.json 。 您可以在这里欣赏这些美丽的types: https : //github.com/googleapis/nodejs-firestore/blob/master/types/firestore.d.ts 。