Skip to content

Commit 6498084

Browse files
committed
Apply code quality suggesitions
1 parent 5fac898 commit 6498084

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

lib/extract/TypeScriptSourceFile.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class TypeScriptSourceFile {
6464
this.processNode(this.getSourceFile(), extractions);
6565
}
6666

67-
private processNode(node: ts.Node, extractions = this.extractions) {
67+
private processNode(node: ts.Node, extractions: Extractions) {
6868
if (TypeScriptSourceFile.isTemplateString(node)) {
6969
this.processTemplateString(node, this.getSourceFile(), extractions);
7070
}
@@ -84,18 +84,17 @@ export class TypeScriptSourceFile {
8484
sourceFile: ts.SourceFile,
8585
extractions: Extractions,
8686
) {
87-
let templateString: string;
88-
const tpl = node.template;
89-
if (ts.isNoSubstitutionTemplateLiteral(tpl)) {
90-
templateString = escapeKey(tpl.text);
91-
} else if (ts.isTemplateExpression(tpl)) {
92-
let templateParts = escapeKey(tpl.head.text);
93-
tpl.templateSpans.forEach((span, index) => {
94-
templateParts += "{" + index + "}" + escapeKey(span.literal.text);
87+
let templateString = "";
88+
const template = node.template;
89+
if (ts.isNoSubstitutionTemplateLiteral(template)) {
90+
templateString = escapeKey(template.text);
91+
} else if (ts.isTemplateExpression(template)) {
92+
let combinedTemplateParts = escapeKey(template.head.text);
93+
template.templateSpans.forEach((span, index) => {
94+
combinedTemplateParts += "{" + index + "}" +
95+
escapeKey(span.literal.text);
9596
});
96-
templateString = templateParts;
97-
} else {
98-
templateString = "";
97+
templateString = combinedTemplateParts;
9998
}
10099
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
101100
extractions.addExtraction(templateString, this.fileName, line + 1);

0 commit comments

Comments
 (0)