在typescript中使用rxjs时会出现错误

时间:2016-08-10 13:36:29

标签: javascript typescript rxjs

我通过以下命令下载了rxjs:

npm install @reactivex/rxjs
文件夹src中的

包含许多ts文件: enter image description here

然后我将src文件夹复制到基于asp.net核心的项目中: enter image description here

然后Visual Studio编译器抱怨很多东西: enter image description here

tsconfig.json看起来像:

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "outDir": "../wwwroot/js"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

有什么问题?

1 个答案:

答案 0 :(得分:3)

您可能需要在tsconfig.json文件中定位ES6。 tsconfig.json

"compilerOptions": {
    "target": "ES6"
}

或者,您可能需要安装一个处理Promises(以及更多)的polyfill,并且具有Typescript的类型,例如core-js。

npm install typings core-js
typings install –global –save dt~core-js