0

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.