【发布时间】:2016-08-10 19:09:30
【问题描述】:
我在 Visual Studio Code 中针对 ES6 有一段时间了,但是当我尝试切换到 TypeScript 时,它会抛出以下错误:
生成器仅在面向 ECMAScript 6 时可用
但我的 tsconfig.json 确实有 ES6 目标:
{
"compilerOptions": {
"target": "ES6",
"module": "amd",
"sourceMap": true
}
}
所以我尝试了npm install -g typescript@1.6.0-beta,但看起来 VSCode 不在乎。
目前不支持生成器。
如何让 TypeScript 和生成器在 VS Code 中正常协同工作?
更新
将 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"
但是,在终端中手动使用/usr/local/lib/node_modules/typescript/bin/tsc --target ES6 app.ts 确实有效。
【问题讨论】:
-
如果你弄明白了,请分享!我也很感兴趣
-
@bali182 完成 :) 祝你好运!
-
哇,谢谢,看看这个,它可能值得等到它的测试版和生产版 1.6 发布 :)
标签: node.js typescript ecmascript-6 visual-studio-code