针对ES5的TS 2.1,视觉工作室抱怨异步功能仅在定位ECMAScript 2015或更高版本时可用

时间:2017-02-10 19:24:03

标签: typescript visual-studio-2015 async-await typescript2.1

据我所知,对于TS 2.1.1版本,async / await适用于ES3 / ES5但我仍然收到来自visual studio 2015的关于异步功能无法使用的警告。代码似乎编译和工作,但为什么visual studio 2015会给出此错误消息?

的package.json

"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 }
}

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。这是因为VisualStudio智能手机的打字稿版本仍低于2.1.x。我相信问题的发生是因为这个智能感知器没有从你的package.json获取打字稿(然后我将使用npm安装),但它使用的是VisualStudio的打字稿。

因此,解决方案是更新您的visualStudio的打字稿版本。您可以通过安装the official site of microsoft的打字稿来更新它(目前最新版本是2.4.1)。安装后重新启动visualStudio,希望你的问题能像我一样解决(来自intelliSense的警告消失了)。