79536945

Date: 2025-03-26 18:23:43
Score: 1.5
Natty:
Report link

Based on @fenton solution, but possible to do Object.keys(Color)

export enum Color {
  Green = "GREEN",
  Red = "RED",
}

export namespace Color {
  export declare const values: readonly Color[];
  export declare function stringify(mode: Color): string;
}

Object.setPrototypeOf(Color, {
  values: Object.values(Color),
  stringify: (color: Color): string => {
    switch (color) {
      case Color.Green:
        return "Зеленый";
      case Color.Red:
        return "Красный";
    }
  },
});
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @fenton
  • Low reputation (1):
Posted by: Artur Beltsov