我怎样才能使类型在firebase云功能上运行?

时间:2018-05-01 01:54:00

标签: typescript firebase google-cloud-firestore google-cloud-functions

打字稿类型不适用于firebase-admin: 这是tsconfig.json文件:

"compilerOptions": {
    "lib": [
      "es6",
      "es2015.promise"
    ],
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "jsx": "react",
    "outDir": ".",
    "rootDir": ".",
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": true,
    "experimentalDecorators": true,
    "preserveConstEnums": true,
    "allowJs": true,
    "sourceMap": true,
    "strictNullChecks": true,
    "typeRoots": [          <------ // I tried to use typeRoots with @google-cloud
      "node_modules/@types"         // but it gives errors on tsc
    ]

@ google-cloud / firestore解决打字,但是当我编译&#39; tsc&#39;我明白了:

TS2688: Cannot find type definition file for 'protos'.
TS2688: Cannot find type definition file for 'src'.
TS2688: Cannot find type definition file for 'types'.

1 个答案:

答案 0 :(得分:1)

我在选择TypeScript作为语言时使用firebase init的默认设置,一切正常。 tsconfig.json中没有设置typeRoots属性。它看起来像这样:

{
  "compilerOptions": {
    "lib": ["es6"],
    "module": "commonjs",
    "noImplicitReturns": true,
    "outDir": "lib",
    "sourceMap": true,
    "target": "es6"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}

从此开始,逐步添加额外的东西,以找出导致问题的原因。