【问题标题】:How to compile several Typescript files on Visual Studio Code如何在 Visual Studio Code 上编译多个 Typescript 文件
【发布时间】:2015-12-02 06:43:09
【问题描述】:

我使用的是 Linux,Visual Studio Code。我有一个项目有几个 .ts (typescript) 文件,我需要一次编译它们。

问题是我在 /src 文件夹中有这些文件,我想将它们编译到另一个文件夹,所以我还必须指定输出文件夹。

谢谢

【问题讨论】:

    标签: visual-studio typescript


    【解决方案1】:

    所以我还必须指定输出文件夹。

    tsconfig.json 中使用outDir

    仅使用tasks.json

    然后将--outDir dirPath 作为标志提供给tsc

    【讨论】:

    • 我好像没有tsconfig.json...只有tasks.json
    • 然后使用--outDir编译器标志
    • 您会将tasks.json 解决方案添加到您的答案中吗?
    【解决方案2】:

    tsconfig.json

    {
        "compilerOptions": {
            "sourceMap":  true, 
            "outFile": "main.js"
        },
        "files": [
            "main.ts",
            "car.ts"
        ]
    }
    

    tasks.json

    您必须在“tasks.json”中省略“args”选项,然后才会使用 tsconfig.json 中的参数!我在这里找到了答案:http://github.com/Microsoft/typescript/wiki/tsconfig.json。它说:在命令行上指定输入文件时,将忽略 tsconfig.json 文件

    来自https://stackoverflow.com/a/33874319/4339170

    【讨论】:

      猜你喜欢
      • 2015-07-10
      • 2020-08-23
      • 1970-01-01
      • 2020-09-04
      • 2018-04-14
      • 2017-08-02
      • 2012-10-30
      • 1970-01-01
      • 2018-03-12
      相关资源
      最近更新 更多