summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-09-27 11:06:46 +0100
committerMichael Williamson <mike@zwobble.org>2026-09-27 11:08:39 +0100
commit9a945c589891ab00b1b8ef5280e31e97a4f29435 (patch)
tree5b4ccffa3ef09780a7b9aba20c52afe371669281
parentbc817ec7c383a015daf015626ef71f6d071b519c (diff)
Generate name for TypeScript symbols
-rw-r--r--examples/03-sum/output/typescript/src/shapes.ts4
-rw-r--r--examples/04-enum/output/typescript/src/numbers.ts6
-rw-r--r--examples/13-inductive-data-types/output/typescript/src/arithmetic.ts4
-rw-r--r--examples/14-inductive-data-types-separate-namespaces/output/typescript/src/data/a.ts2
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java3
5 files changed, 9 insertions, 10 deletions
diff --git a/examples/03-sum/output/typescript/src/shapes.ts b/examples/03-sum/output/typescript/src/shapes.ts
index 9758cd6..144db10 100644
--- a/examples/03-sum/output/typescript/src/shapes.ts
+++ b/examples/03-sum/output/typescript/src/shapes.ts
@@ -8,7 +8,7 @@ type Shape = Rectangle | Triangle;
export {type Shape};
class Rectangle {
- public static readonly $tag = Symbol();
+ public static readonly $tag = Symbol("Rectangle");
public readonly $tag: typeof Rectangle.$tag = Rectangle.$tag;
@@ -28,7 +28,7 @@ class Rectangle {
export {Rectangle};
class Triangle {
- public static readonly $tag = Symbol();
+ public static readonly $tag = Symbol("Triangle");
public readonly $tag: typeof Triangle.$tag = Triangle.$tag;
diff --git a/examples/04-enum/output/typescript/src/numbers.ts b/examples/04-enum/output/typescript/src/numbers.ts
index 14c8905..cbe9ed1 100644
--- a/examples/04-enum/output/typescript/src/numbers.ts
+++ b/examples/04-enum/output/typescript/src/numbers.ts
@@ -3,11 +3,11 @@
// Custom area start: imports
// Custom area end: imports
-const SmallNumber$Zero: unique symbol = Symbol();
+const SmallNumber$Zero: unique symbol = Symbol("Zero");
-const SmallNumber$One: unique symbol = Symbol();
+const SmallNumber$One: unique symbol = Symbol("One");
-const SmallNumber$Two: unique symbol = Symbol();
+const SmallNumber$Two: unique symbol = Symbol("Two");
const SmallNumber = {
Zero: SmallNumber$Zero as typeof SmallNumber$Zero,
diff --git a/examples/13-inductive-data-types/output/typescript/src/arithmetic.ts b/examples/13-inductive-data-types/output/typescript/src/arithmetic.ts
index 486ac66..5f5926b 100644
--- a/examples/13-inductive-data-types/output/typescript/src/arithmetic.ts
+++ b/examples/13-inductive-data-types/output/typescript/src/arithmetic.ts
@@ -8,7 +8,7 @@ type Expression = Add | Const;
export {type Expression};
class Add {
- public static readonly $tag = Symbol();
+ public static readonly $tag = Symbol("Add");
public readonly $tag: typeof Add.$tag = Add.$tag;
@@ -28,7 +28,7 @@ class Add {
export {Add};
class Const {
- public static readonly $tag = Symbol();
+ public static readonly $tag = Symbol("Const");
public readonly $tag: typeof Const.$tag = Const.$tag;
diff --git a/examples/14-inductive-data-types-separate-namespaces/output/typescript/src/data/a.ts b/examples/14-inductive-data-types-separate-namespaces/output/typescript/src/data/a.ts
index f8360f5..80f6ea9 100644
--- a/examples/14-inductive-data-types-separate-namespaces/output/typescript/src/data/a.ts
+++ b/examples/14-inductive-data-types-separate-namespaces/output/typescript/src/data/a.ts
@@ -10,7 +10,7 @@ type A = A1;
export {type A};
class A1 {
- public static readonly $tag = Symbol();
+ public static readonly $tag = Symbol("A1");
public readonly $tag: typeof A1.$tag = A1.$tag;
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 353f07b..508de55 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
@@ -369,8 +369,7 @@ public class TypescriptTypesGenerator implements Generator {
private TypescriptExpression generateSymbol(TypescriptIdentifier name) {
return new TypescriptCall(
TypescriptTypes.SYMBOL,
- // TODO: add type name as string
- List.of()
+ List.of(new TypescriptStringLiteral(name.value()))
);
}
}