zero_coding zero_coding - 3 months ago 30
TypeScript Question

Errors appear when using rxjs in typescript

I downloaded rxjs via with following command:

npm install @reactivex/rxjs


in the folder src contains many ts files:
enter image description here

Then I copied the src folder into my project based on asp.net core as:
enter image description here

Then Visual Studio compiler complains a lot of things:
enter image description here

The
tsconfig.json
looks like:

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


What is wrong?

Answer

You may need to target ES6 in your tsconfig.json file. tsconfig.json

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

Or, you may need to install a polyfill that handles Promises (and more) and has typings for Typescript, like core-js.

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