Firebase @ google-cloud / firestore软件包Typescript错误重复的标识符“ DocumentData”

Ahm*_*ged 3 firebase typescript google-cloud-functions google-cloud-firestore

我正在使用使用Typescript的Firebase云函数,并且一切正常。在我的代码中,我创建了类型变量之一DocumentReferenceGeoPoint这就是make vs代码将其导入

import { GeoPoint, DocumentReference } from '@google-cloud/firestore'

function offsetSlightly(location:GeoPoint) {
     //some code here
  return new GeoPoint(latitude, longitude)
}
Run Code Online (Sandbox Code Playgroud)

所以我需要添加使用命令添加的那个节点模块

npm install @google-cloud/firestore

当我尝试部署时,每件事看起来都很好,我得到了很多重复的标识符,例如DocumentData,UpdateData,GeoPoint ..etc

错误:

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};
Run Code Online (Sandbox Code Playgroud)

那就是我的package.json {

  "name": "functions",
  "scripts": {
    "lint": "tslint --project tsconfig.json",
    "build": "tsc",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "main": "lib/index.js",
  "dependencies": {
    "@google-cloud/firestore": "^0.14.1",
    "firebase-admin": "^5.12.1",
    "firebase-functions": "^1.0.4",
    "nodemailer": "^4.6.4",
    "twilio": "^3.16.0"
  },
  "devDependencies": {
    "tslint": "^5.10.0",
    "typescript": "^2.9.2"
  },
  "private": true
}
Run Code Online (Sandbox Code Playgroud)

我不知道问题所在,但我认为这是package中的一些冲突。我是android开发人员,对Node有一点经验。有什么帮助吗?

Vas*_*rov 5

无需从独立的Firestore SDK导入类,只需在Firebase Admin SDK的Firestore上创建类型别名:

import * as admin from 'firebase-admin';

type GeoPoint = admin.firestore.GeoPoint
type DocumentReference = admin.firestore.DocumentReference
Run Code Online (Sandbox Code Playgroud)