【问题标题】:Two tsconfig files with Dependency issue两个存在依赖问题的 tsconfig 文件
【发布时间】:2016-11-18 10:17:50
【问题描述】:

我有两个 ts 配置文件的解决方案。 该解决方案具有such 文件夹结构。

根 tsconfig.json:

{
    "compilerOptions": {
        "declaration": true,
        "outFile":  "Test/Namespace.js" 
    }
}

Test\tsconfig.json 为空。

Test.ts 只有在创建 Namespace.d.ts 时才能正常工作,但在这种情况下构建会崩溃。很明显的原因是编译顺序,Test\tsconfig.json 先编译。

有没有办法更改 tsconfig 文件的编译顺序,或者在其他 tsconfig 错误的情况下继续构建?

【问题讨论】:

    标签: json visual-studio typescript tsconfig


    【解决方案1】:

    在 tsconfig.json 中使用 "files" 属性来指定发送到 outFile 的文件的顺序。

    例如: json { "compilerOptions": { "declaration": true, "outFile": "Test/Namespace.js" }, "files": [ "namespace.ts", "test.ts" ] }

    更多详情请见https://github.com/Microsoft/TypeScript/wiki/FAQ#how-do-i-control-file-ordering-in-combined-output---out-

    【讨论】:

    • 其实我在说另外一件事。问题在于两个“tsconfig.json”文件的编译顺序。因此,这与“tsconfig.json”之一中的编译顺序无关。文件 "Test.ts" 依赖于根 "tsconfig.json" 的输出声明文件。但是之前没有生成 d.ts 文件。我已在 github 上的 issue report 附上了一个简单的解决方案。
    • MSBuild 中的顺序是它们在文件中出现的顺序。确保这两个 tsconifg.json 文件按此顺序列出。您还可以将它们放在两个不同的 MSBuild 项目中,并从一个项目添加到另一个项目。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-04
    • 2018-04-29
    • 1970-01-01
    • 2022-01-07
    相关资源
    最近更新 更多