diff options
| -rw-r--r-- | src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java | 10 |
1 files changed, 10 insertions, 0 deletions
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<TypescriptStatement> 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( |
