Show enum description instead of value when debugging

Viewed 599

I work with visual studio code and I'm using the following enum:

export enum Car {
    Toyota,
    BMW,
    Audi,...
}

When I debug, the debugger shows the value 0, 1 instead of the enum description like Toyota, BMW. Which settings or code modification do I need to make the debugger show me the enum description?

1 Answers

If don't need numeric values of enum members, you can use 'String Enum', according to the docs it would look like:

export enum Car {
    Toyota = "Toyota",
    BMW = "BMW",
    Audi = "Audi"
}

In that case members and values would be the same, and during dubugging you will get enum descriptions like Toyota, BMW, etc.

Related