From 865b4f3941e28fd5891c7f80c2653408767a1199 Mon Sep 17 00:00:00 2001 From: Stanislav Berkov Date: Wed, 31 Jan 2024 19:11:40 -0700 Subject: [PATCH] Add type having enum values to mimic enum behavior --- src/ts/enum.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ts/enum.ts b/src/ts/enum.ts index 1ced206..59e8f1f 100644 --- a/src/ts/enum.ts +++ b/src/ts/enum.ts @@ -14,5 +14,6 @@ export function printEnum(enumDescriptor: EnumDescriptorProto, indentLevel: numb printer.printLn(`}`); printer.printEmptyLn(); printer.printLn(`export const ${enumDescriptor.getName()}: ${enumInterfaceName};`); + printer.printLn(`export type ${enumDescriptor.getName()} = ${enumInterfaceName}[keyof ${enumInterfaceName}];`); return printer.getOutput(); }