在 Visual Studio Code 中,我在 tsconfig.json 中的代码中有以下代码
{
"version": "1.6.0",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"watch": true,
"experimentalAsyncFunctions": true,
"isolatedModules": false,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true
},
...
}
如您所见,watch
选项为 true。好吧,看起来这不足以像 atom-typescript 那样将 .ts 文件编译为 .js。基本上,新编译的 .js 在保存 .ts 时应该在 .ts 文件的同一目录中。
另外,我想避免在我的根项目中使用 gulp,因为我已经将 gulpfile.coffee 用于其他方式。有人有线索吗?
最佳答案
使用最新版本的 VS Code 1.7.2 和 Typescript 2.0.10,您只需要在 .vscode/tasks.json
中包含以下代码
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-w", "-p", "."],
"showOutput": "silent",
"isWatching": true,
"problemMatcher": "$tsc-watch"
}
不需要 tsconfig.json
中的 watch
选项。
关于typescript - VS 代码 : watch typescript on save file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34620818/