我在Visual Studio Code中已经将ES6定位了一段时间,但是当我尝试切换到TypeScript时,它会抛出错误,例如:
生成器仅在定位ECMAScript 6时可用
但我的tsconfig.json确实有ES6目标:
{
"compilerOptions": {
"target": "ES6",
"module": "amd",
"sourceMap": true
}
}
Run Code Online (Sandbox Code Playgroud)
所以我试过npm install -g typescript@1.6.0-beta但看起来VSCode并不关心.
目前不支持生成器.
如何在VS Code中使TypeScript和生成器一起正常工作?
更改typescript.tsdk为1.6二进制文件似乎修复了IntelliSense错误,但是这个tasks.json仍打印出来error TS1220: Generators are only available when targeting ECMAScript 6 or higher.:
"version": "0.1.0",
"command": "/usr/local/lib/node_modules/typescript/bin/tsc",
"showOutput": "silent",
"windows": {"command": "tsc.exe"},
"isShellCommand": true,
"args": ["app.ts"],
"problemMatcher": "$tsc"
Run Code Online (Sandbox Code Playgroud)
但是,/usr/local/lib/node_modules/typescript/bin/tsc --target ES6 app.ts在终端中手动使用确实有效.