Skip to content

Commit 6aec27a

Browse files
authored
Merge pull request #7 from wuespace/fix-extraction-escape-key
Escape keys in extraction
2 parents 226fc57 + e1913f1 commit 6aec27a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/extract/TypeScriptSourceFile.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expandGlob } from "@std/fs";
22
import * as ts from "typescript";
33
import type { Extractions } from "./Extractions.ts";
4+
import { escapeKey } from "../common/escapeKey.ts";
45

56
/**
67
* Represents a TypeScript source file and provides utilities for parsing and extracting
@@ -86,12 +87,12 @@ export class TypeScriptSourceFile {
8687
let templateString: string;
8788
const tpl = node.template;
8889
if (ts.isNoSubstitutionTemplateLiteral(tpl)) {
89-
templateString = tpl.text;
90+
templateString = escapeKey(tpl.text);
9091
} else if (ts.isTemplateExpression(tpl)) {
91-
let parts = tpl.head.text;
92+
let parts = escapeKey(tpl.head.text);
9293
tpl.templateSpans.forEach((_, index) => {
9394
const span = tpl.templateSpans[index];
94-
parts += "{" + index + "}" + span.literal.text;
95+
parts += "{" + index + "}" + escapeKey(span.literal.text);
9596
});
9697
templateString = parts;
9798
} else {

0 commit comments

Comments
 (0)