使用 Visual Studio 创建的项目之外的 TypeScript 编译

TypeScript compilation outside of project created with Visual Studio

我继承了一个使用 TypeScript 构建的大型 LOB 应用程序。该项目在任何文件中都没有参考路径,因为它是使用 Visual Studio 2013 设置和创建的 - Visual Studio 似乎有一些魔力,它可以获取全局 TypeMaps 本身。 嗤之以鼻.

当前的构建过程是使用 Grunt 复制 已编译的 .js 文件(在 Visual Studio 中保存时生成)到构建目录 - 不是实际编译它们。

(为了进一步强调这一点,Grunt 编译任何 TypeScript)。

此构建过程现在不再可接受,因为我正在使用 Team City 和命令行 tsc 通过持续集成过程将应用程序移动到构建。exe/Grunt - 所以当存储库在那里签出时显然项目中没有生成.js文件。

在当前状态下,尝试使用命令行 tsc 时出现大量编译错误。exe/Grunt 编译 TypeScript 文件,我想是因为应用程序未使用引用路径?

这是否意味着我需要将所有相关的引用路径添加到项目中的每个文件?

有没有人对这种设置有任何经验,可以为我指明正确的方向来管理这些参考路径和构建过程?

谢谢

In its current state there is a host of compilation errors when trying to use Command Line tsc.exe/Grunt to compile the TypeScript files, I think due to the fact that the application is not using reference paths

没有。您应该使用 tsconfig.json 来创建 编译上下文 .

更多

https://basarat.gitbooks.io/typescript/content/docs/project/project.html

已找到解决方案。

在 grunt-ts 任务中使用 Visual Studio 配置选项,我已将任务设置为专门使用项目 .csprog 和 TypeScript 1.4 编译器(我们被锁定在该编译器中)。

我的 grunt-ts 任务配置:

    ts: {
        default: {
            vs: "Consortium.Client.Web.csproj",
            options: {
                compiler: "1.4/tsc"
            }
        }
    }

我希望这对其他人有帮助。