如何在服务器上使用Typescript dom lib?

时间:2017-11-28 10:30:28

标签: typescript google-cloud-functions

我正在为Google云功能编写代码。在这里,我想使用URL标准,包括URLSearchParams。我发现它们是Typescript dom lib的一部分,所以我已将它添加到我的tsconfig libs设置中。

但是当我编译和部署云功能时,我收到一个运行时错误,说没有定义URLSearchParams。

我错过了什么?我正在使用TS 2.6

---编辑---

这是我的配置:

{
  "compilerOptions": {
    /* Basic Options */
    "target": "es6",
    "module": "commonjs",
    "lib": ["es6", "es7", "esnext", "dom"],

    "sourceMap": true /* Generates corresponding '.map' file. */,
    "outDir": "build" /* Redirect output structure to the directory. */,
    "removeComments": true /* Do not emit comments to output. */,

    /* Strict Type-Checking Options */
    "strict": true /* Enable all strict type-checking options. */,

    /* Additional Checks */
    "noUnusedLocals": true /* Report errors on unused locals. */,
    "noUnusedParameters": true /* Report errors on unused parameters. */,
    "noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
    "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,

    "plugins": [{ "name": "tslint-language-service" }],
    "skipLibCheck": false
  },
  "include": ["src/**/*"],
  "exclude": ["build"]
}

和package.json依赖项:

  "dependencies": {
    "circular-json": "^0.4.0",
    "es6-promisify": "^5.0.0",
    "firebase-admin": "^5.5.0",
    "firebase-functions": "^0.7.3",
    "invariant": "^2.2.2",
    "joi": "12",
    "lodash": "^4.17.4",
    "node-fetch": "^2.0.0-alpha.9"
  },
  "devDependencies": {
    "@types/circular-json": "^0.4.0",
    "@types/invariant": "^2.2.29",
    "@types/joi": "^13.0.0",
    "@types/lodash": "^4.14.85",
    "@types/node": "^8.0.52",
    "@types/node-fetch": "^1.6.7",
    "cpy-cli": "^1.0.1",
    "del-cli": "^1.1.0",
    "firebase-tools": "^3.15.1",
    "tslint": "^5.8.0",
    "tslint-config-prettier": "^1.6.0",
    "tslint-language-service": "^0.9.6",
    "typescript": "2.6"
  }

0 个答案:

没有答案