Skip to content

String Based Enum - Reverse Mapping Problem #21935

Closed
@kannanwisen

Description

@kannanwisen

My TypeScript Version is 2.7.1

  1. enum Country{
  2. India = "INR",
    
  3. France = "EUR",
    
  4. USA = "USD",
    
  5. Germany = France
    
  6. }
  7. let vx : Country = Country.India;
  8. console.log("vx is "+vx);
  9. console.log("enum name is "+Country[vx]);

The output are as follows

vx is INR
enum name is undefined

In Line 9, the reverse mapping is not working for string based enum.

Thanks

Kannan Wisen

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions