【问题标题】:Using tsconfig.json with Visual Studio 2013? (web project)将 tsconfig.json 与 Visual Studio 2013 一起使用? (网络项目)
【发布时间】:2015-10-19 21:32:12
【问题描述】:

我在我的 Web 项目中使用 Angular 2,因此需要 TypeScript 来支持诸如 @View 之类的实验性装饰器。这可以在 tsconfig.json 中使用"experimentalDecorators": true 完成,但我在 Visual Studio 的项目设置中看不到这样的选项。 (我创建了一个 TypeScript 项目。)因此,我需要 Visual Studio 来检测和使用我的 tsconfig.json 文件。

我已经阅读了 Visual Studio 应该在项目根目录中找到并使用 tsconfig.json 的各种在线位置。然而,这并没有发生。我正在使用 Visual Studio 2013 Update 4 -- 并在撰写本文时升级到 Update 5。

有谁知道如何让 Visual Studio 2013(不是 Visual Studio Code,而不是 Visual Studio 2015)使用 tsconfig.json 文件?也许它需要位于解决方案的根目录而不是项目的根目录中?

我可以尝试添加一个预构建事件来直接调用 tsc 失败......但这似乎很草率。

【问题讨论】:

    标签: visual-studio-2013 web-essentials typescript1.5


    【解决方案1】:

    我也在找这个。 Visual Studio 2013-2015 似乎还不支持 tsconfig.json。目前您需要编辑您的项目文件。

    编辑: 随着 Typescript 1.8 版本的 Visual Studio 2015 接缝完全支持 .tsconfig。见http://www.typescriptlang.org/docs/release-notes/typescript-1.8.html

    【讨论】:

    • 是的,这也是我采用的“解决方案”。
    • tsconfig.json 模拟exclude 的等效.csproj 属性是什么?我需要让VS忽略例如node_modules 文件夹。
    • @superjos 您不需要将 exclude 与 .csproj 一起使用,只需将此文件夹从您的项目中排除(您永远不应该将 note_modules 之类的文件夹提交到源代码管理)。这是完整的映射列表typescriptlang.org/docs/handbook/…
    • 感谢您的建议。 node_modules 已经从 VS 项目中排除(当然也被源代码管理忽略)。但是,在 regular(无论这意味着什么)项目下,在项目根目录下找到 node_modules 目录是很常见的。
    • @superjos 可能我不明白你的问题。在我当前的项目中,我在 web 项目下有 node_modules,并且我的 note_modules 源代码不是由 VS 编译的。您目前有什么问题?
    【解决方案2】:

    以下问题:What are the TypeScript project build configuration options? 指向一个 .targets 文件,其中定义了 TypeScript 配置选项。

    您可以手动修改该 .targets 文件以添加对实验性装饰器的支持,但这是不可扩展的,因为您必须对每个开发人员的机器执行此操作。

    【讨论】:

      猜你喜欢
      • 2023-03-20
      • 2012-12-04
      • 1970-01-01
      • 2014-02-03
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多