Typescript TS 2.1针对ES5的visual studio异步功能仅在针对ECMAScript 2015或更高版本时可用
据我所知,在TS的2.1.x版本中,async/await适用于ES3/ES5,但我仍然收到visual studio 2015关于异步函数不可用的警告。代码似乎可以编译和工作,但为什么visual studio 2015会给出此错误消息 package.jsonTypescript TS 2.1针对ES5的visual studio异步功能仅在针对ECMAScript 2015或更高版本时可用,typescript,visual-studio-2015,async-await,typescript2.1,Typescript,Visual Studio 2015,Async Await,Typescript2.1,据我所知,在TS的2.1.x版本中,async/await适用于ES3/ES5,但我仍然收到visual studio 2015关于异步函数不可用的警告。代码似乎可以编译和工作,但为什么visual studio 2015会给出此错误消息 package.json "typescript": "~2.1.6" tsconfig { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "n
"typescript": "~2.1.6"
tsconfig
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmitHelpers": true,
"strictNullChecks": false,
"baseUrl": "./src",
"paths": {
},
"lib": [
"dom",
"es6"
],
"types": [
"node",
"source-map"
]
},
"exclude": [
"node_modules",
"dist",
"**/*.aot.ts",
"**/*.ngfactory.ts"
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": { "rewriteTsconfig": false }
}
我也有同样的问题。这是因为VisualStudio的intelliSense的typescript版本仍然低于2.1.x。我认为出现问题是因为intelliSense没有从您的
包.json
中获取类型脚本(我想随后将使用npm
安装),但它使用VisualStudio的类型脚本
因此,解决方案是更新visualStudio的typescript版本。您可以通过从安装typescript来更新它(当前最新版本为2.4.1)。安装后重新启动visualStudio,希望您的问题能像我一样得到解决(intelliSense发出的警告消失了)