Skip to content

Preserve enum references #2322

Closed
Closed
@ivogabe

Description

@ivogabe

There is already an option to preserve const enums declarations in the generated javascript, but (as far as I know) not an option to preserve references to these enums. Currently enum references are replaced by there integer value. This is fine in most situations, but not in all.

I'm working on a new version of gulp-typescript that supports multiple versions of TypeScript, and different versions of TypeScript might have different indices for syntax kinds, so I have to keep the references to the enum so at runtime the right number is found. I temporary solved it by casting to any, as you can see here.

Suggestion: add a new option preserveEnumReferences. When this is active, references to enums will be emitted using normal JavaScript property access (exactly what happens after the work-around with casts).

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions