Skip to content

Using Enum in a separate file, inconsistently compiles on save vs project build #2422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amg-argh opened this issue Mar 19, 2015 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@amg-argh
Copy link

When creating and using an enum (TypeScript 1.4, Visual Studio 2013). When I build the project the enum value is compiled to a number, but if I save the file the compiled output is the full name of the enum. For example:

// enum.ts
enum SomeEnum {
    One = 1,
    Two = 2
}
// consumer.ts
class Consumer {
    public doSomething(): void {
        var x: SomeEnum = SomeEnum.One;
    } 
} 

When the project is built, it compiles to:

var Consumer = (function () {
    function Consumer() {
    }
    Consumer.prototype.doSomething = function () {
        var x = 1 /* One */;
    };
    return Consumer;
})();

However when I edit and save "consumer.ts" it compiles to:

var Consumer = (function () {
    function Consumer() {
    }
    Consumer.prototype.doSomething = function () {
        var x = SomeEnum.One;
    };
    return Consumer;
})();

The issue is that the enum values are sitting in a DomainModels.d.ts file (that is converted from C# using TypeLite). So the definition of the enum is never included in the output.

The preferred output would be always compiling to a number.

@NoelAbrahams
Copy link

Possible duplicate of #1812

@mhegazy mhegazy added the Duplicate An existing issue was already created label Mar 19, 2015
@mhegazy mhegazy closed this as completed Mar 19, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants