编译typescript \ ts文件作为Visual Studio 2017中构建过程的一部分

时间:2017-08-15 04:02:24

标签: typescript visual-studio-2017 tsconfig

在VS2017中,我有一个WebSite项目,我已经添加了一个tsconfig.json文件。作为构建的一部分,我应该如何自动生成ts文件中的js文件?

我删除tsconfig.json文件,编译保存选项将起作用,但通过添加它,即使编译保存也不起作用。

tsconfig.json文件内容的一个示例:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true
    }
}

2 个答案:

答案 0 :(得分:0)

可能是因为缺少csproj中的打字稿。 如果您使用NET CORE,这可以帮助Compile TypeScript on build

否则创建新项目并将csproj配置与您的配置进行比较以修复打字稿。

答案 1 :(得分:0)

您需要在tsconfig文件中设置compile on save标志,以便在save:

上激活编译
{
   "compileOnSave": true,
   "compilerOptions": {
       "noImplicitAny" : true
   }
}

https://www.typescriptlang.org/docs/handbook/tsconfig-json.html