typescript - VS 代码 : watch typescript on save file

标签 typescript task visual-studio-code tsc tsd

在 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/

相关文章:

javascript - 枚举的 typescript 类型别名

javascript - 无法设置未定义的属性 'someProperty' - Angular Typescript

asp.net - 找不到模块 '@angular/core' Visual Studio 2017

android - 将不同的行 ID 从 appWidget 传递到任务中的单个 Activity 实例

dart - 为什么标签缩进在 VSCode 中不一致? ( Dart 语言)

html - ionic2 如何获取其他页面的输入数据

multithreading - JavaFX 任务线程未终止

.net-4.0 - Foreach 循环和任务

javascript - 如何从 Visual Studio Code API 打开浏览器

c++ - 无法使用 Atmel 寄存器编译 Arduino 代码