【问题标题】:Visual Studio generates wrong javascript from typescript when saving ts file (works when building project)保存 ts 文件时,Visual Studio 从打字稿生成错误的 javascript(在构建项目时有效)
【发布时间】:2015-02-18 04:25:02
【问题描述】:

我对打字稿有奇怪的问题。我将枚举放在单独的 .ts 文件中,当我保存使用枚举的另一个文件时,Visual Studio 编译不正确的 javascript,但是当我构建项目时,正确生成了 javascript。

有谁知道如何保存工作(因为每次我在调试时更改 .ts 文件时构建项目非常繁琐)?

例子:

MyEnums.ts

module MyEnums {
    export const enum MyEnum {
        val1 = 1,
        val2 = 2,
        val3 = 3
    }
} 

App.ts

module App {
    console.log(MyEnums.MyEnum.val1);
}

保存 App.ts 时的输出(不正确)

var App;
(function (App) {
    console.log(MyEnums.MyEnum.val1);
})(App || (App = {}));

构建项目时的输出(正确)

var App;
(function (App) {
    console.log(1 /* val1 */);
})(App || (App = {}));

我正在使用 Typescript 1.4 和 Visual Studio 2013 Update 4

【问题讨论】:

    标签: visual-studio typescript


    【解决方案1】:

    这是 TypeScript 语言服务中的一个错误。请参阅 this thread 那里有 a link 到更新的 typescriptservices.js 您可以修补以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-14
      • 1970-01-01
      • 1970-01-01
      • 2020-01-08
      • 2016-08-05
      • 2014-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多