From 26d06c662fe35c32d9b777b2c624730cb8bee53b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 4 Sep 2026 10:34:24 +0100 Subject: Add docs --- .../generators/typescripttypes/TypescriptTypesGenerator.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java index d7309eb..b983873 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java @@ -118,6 +118,16 @@ public class TypescriptTypesGenerator implements Generator { private List generateEnumDefinition( TypedEnumDefinitionNode enumDefinition ) { + // To have TypeScript treat a symbol as unique, we have to explicitly + // mark it with `unique symbol`. Since this can only be used on + // declarations, we have to declare a const variable for each variant. + // + // When assigning those symbols to the object for the enum, we then have + // to cast the values to the type of that symbol, otherwise TypeScript + // will widen the type to be a non-unique symbol. + // + // See: https://github.com/microsoft/TypeScript/pull/54778 + var typescriptTypeName = this.typescriptGenerator.generateTypeName(enumDefinition.name()); return Lists.concat(List.of( -- cgit v1.2.3