node.js - 编译 Node App 时出错 - 变量 'Promise' 的类型必须为 'any',但此处的类型为 'PromiseConstructor'

标签 node.js typescript

我正在运行“tsc”并收到以下错误

typings/browser/ambient/es6-shim/index.d.ts(554,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'Promise' must be of type 'any', but here has type 'PromiseConstructor'. 
typings/globals/require/index.d.ts(367,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.

打字.json

{
  "ambientDependencies": {
    "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654",
    "jasmine": "registry:dt/jasmine#2.2.0+20160412134438"
  },
  "dependencies": {
    "requirejs": "registry:npm/requirejs#2.2.0+20160319062357"
  }
}

包.json

 "dependencies": {
    "@angular/common": "2.0.0-rc.1",
    "@angular/compiler": "2.0.0-rc.1",
    "@angular/core": "2.0.0-rc.1",
    "@angular/http": "2.0.0-rc.1",
    "@angular/platform-browser": "2.0.0-rc.1",
    "@angular/platform-browser-dynamic": "2.0.0-rc.1",
    "@angular/router": "2.0.0-rc.1",
    "@angular/router-deprecated": "2.0.0-rc.1",
    "@angular/upgrade": "2.0.0-rc.1",
    "angular2-in-memory-web-api": "0.0.7",
    "bootstrap": "^3.3.6",
    "es6-shim": "^0.35.0",
    "express": "^4.13.4",
    "promise": "^7.1.1",
    "reflect-metadata": "^0.1.3",
    "request": "^2.72.0",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.27",
    "xml2js": "^0.4.16",
    "zone.js": "^0.6.12"
  },

最佳答案

我能够通过逐字编辑它并修改它提示的行来解决这个问题,但我确信这是一种解决方法,而不是正确的解决方法

typings/browser/ambient/es6-shim/index.d.ts 第 554 行让它输入任何 typings/globals/require/index.d.ts 第 367 行使其键入 NodeRequire

关于node.js - 编译 Node App 时出错 - 变量 'Promise' 的类型必须为 'any',但此处的类型为 'PromiseConstructor',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37398967/

相关文章:

mysql - NodeJs MySql 多次更新

javascript - 如何在云函数中调用 firestore getDocument 并使用云函数将其响应发送回客户端?

typescript - 谁能解释一下这个 TypeScript 语句吗?

angular - 服务中不能使用渲染器?

node.js - Mongoose 更新总是给我 TypeError : Cannot set property '__v' of undefined

node.js - 当数据库中存在空字段时,为什么 Mongoose 会响应空字段

node.js - 如何让 puppeteer 在 Google Cloud Run/Cloud Build 中工作?

javascript - 将值传递给构造函数时使构造函数正常工作的问题

javascript - 如何使用 array.from 和 new set 方法返回多个值

javascript - 如何使用柯里化(Currying)有条件地将数据传递给函数