diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-09-27 11:07:52 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-09-27 11:08:41 +0100 |
| commit | 5f436d96a3c0b9a0393287e441ac2e53a61f22fa (patch) | |
| tree | 9eff620654f87bb9a6491a110abbb1c831543a65 | |
| parent | 9a945c589891ab00b1b8ef5280e31e97a4f29435 (diff) | |
Escape string literals in import statements
| -rw-r--r-- | src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java index 46ccdc1..3d5d99f 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java @@ -91,10 +91,7 @@ public class TypescriptWriter implements AutoCloseable { ); this.writer.write("} from "); - // TODO: proper string literals - this.writer.write("\""); - this.writer.write(importDeclaration.fromModule()); - this.writer.write("\""); + this.writeStringLiteral(importDeclaration.fromModule()); this.writer.write(";"); this.writer.newLine(); } @@ -450,9 +447,13 @@ public class TypescriptWriter implements AutoCloseable { } private void writeStringLiteral(TypescriptStringLiteral stringLiteral) throws IOException { + this.writeStringLiteral(stringLiteral.value()); + } + + private void writeStringLiteral(String value) throws IOException { this.writer.write("\""); this.writer.write( - stringLiteral.value() + value .replace("\\", "\\\\") .replace("\"", "\\\"") .replace("\n", "\\n") |
