Vertigo
Vertigo

Reputation: 2746

Visual Studio generates wrong javascript from typescript when saving ts file (works when building project)

I have strange problem with typescript. I have my enums in separate .ts file and when I save the other file that is using enums, visual studio compiles incorrect javascript, but when I build the project, javascript is generated correctly.

Does anyone know how to get saving working (as it's quite tedious to build project everytime I change .ts file while debugging)?

Example:

MyEnums.ts

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

App.ts

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

Output (incorrect) when saving App.ts

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

Output (correct) when building project

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

I'm using Typescript 1.4 and Visual Studio 2013 Update 4

Upvotes: 0

Views: 296

Answers (1)

Ryan Cavanaugh
Ryan Cavanaugh

Reputation: 220944

It's a bug in the TypeScript language service. See this thread where there's a link to an updated typescriptservices.js you can patch in to fix the problem.

Upvotes: 2

Related Questions