From d9945c3fd0dfa85bf0ca2bbb3af35af4b25b0fe7 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 30 Aug 2026 13:36:30 +0100 Subject: Support static field declarations in TypeScript AST --- .../output/lang/typescript/TypescriptWriterTests.java | 13 +++++++++++++ .../ast/TypescriptClassFieldDeclarationMatcher.java | 6 ++++++ 2 files changed, 19 insertions(+) (limited to 'src/test/java') diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java index bca5ab3..b0c583f 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java @@ -211,6 +211,19 @@ public class TypescriptWriterTests { assertThat(string, equalTo("public a;")); } + @Test + public void staticClassFieldDeclarationWithoutInitialValue() throws IOException { + var typescript = TypescriptClassFieldDeclaration.arbitrary() + .withVisibility(TypescriptVisibility.PUBLIC) + .withName(id("a")) + .withIsStatic(true) + .build(); + + var string = write(writer -> writer.writeClassElement(typescript)); + + assertThat(string, equalTo("public static a;")); + } + @Test public void classFieldDeclarationWithExplicitType() throws IOException { var typescript = TypescriptClassFieldDeclaration.arbitrary() diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassFieldDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassFieldDeclarationMatcher.java index 718e4ae..62a3f9e 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassFieldDeclarationMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassFieldDeclarationMatcher.java @@ -42,6 +42,12 @@ public final class TypescriptClassFieldDeclarationMatcher implements org.zwobble return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclarationMatcher(submatchers); } + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclarationMatcher withIsStatic(org.zwobble.precisely.Matcher isStatic) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("isStatic", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclaration::isStatic, (org.zwobble.precisely.Matcher) isStatic)); + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclarationMatcher(submatchers); + } + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclarationMatcher withType(org.zwobble.precisely.Matcher> type) { var submatchers = new java.util.ArrayList>(this.submatchers); submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclaration::type, (org.zwobble.precisely.Matcher) type)); -- cgit v1.2.3