Skip to content

"enum" not generating "const enum" in the typescript definition so the typescript compiler does not substitute values #33

@JJ-M

Description

@JJ-M

Installed product versions

  • Visual Studio: 2019 Professional
  • This extension: v2.2.4

Description

In a Typescript Definition file, if you specify an "enum" the typescript compiler treats it as a type, and does not substitute values. If you specify "const enum" the compiler will substitute the values for the enum where it is used in the typescript when generating the javascript file. For a definition generated from the C# it needs to substitute values where used, as the reference to the type is lost on compilation to javascript and you end up with a runtime object not found errors in the browser.

If it is "const enum" the typescript compiler substitutes the values for the enum references in the code and it all works.

Looking at the example for this extension, "public enum" should become "const enum" but the output I'm getting in the d.ts is just "enum".

Steps to recreate

Add an public enum inside a namespace within a .cs file, generate the d.ts file. The generated enum is not prefixed with "const".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions