diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-09-04 10:34:24 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-09-04 10:34:24 +0100 |
| commit | 26d06c662fe35c32d9b777b2c624730cb8bee53b (patch) | |
| tree | d8d9d415d22afc8d2c4dfae7245a834c85ff013c /src | |
| parent | 329b73a28689faa776c82a4e33195a05ef8337ad (diff) | |
Add docs
Diffstat (limited to 'src')
| -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( |
