Skip to content

Commit

Permalink
fix(51072): skip imports in template strings
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Oct 7, 2022
1 parent c18791c commit 8000332
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/services/preProcess.ts
Expand Up @@ -376,7 +376,9 @@ namespace ts {
}
break;
}
token = scanner.scan();
if (length(stack)) {
token = scanner.scan();
}
}
nextToken();
}
Expand Down
16 changes: 16 additions & 0 deletions src/testRunner/unittests/services/preProcessFile.ts
Expand Up @@ -205,6 +205,22 @@ describe("unittests:: services:: PreProcessFile:", () => {
/* eslint-enable no-template-curly-in-string */
});

it("Ignores imports in template strings", () => {
/* eslint-disable no-template-curly-in-string */
test("a ? `&${a}` : `#${b}`;\n\n `import(\"${moduleSpecifier}\").${id}`;",
/*readImportFile*/ true,
/*detectJavaScriptImports*/ true,
{
referencedFiles: [],
typeReferenceDirectives: [],
libReferenceDirectives: [],
importedFiles: [],
ambientExternalModules: undefined,
isLibFile: false
});
/* eslint-enable no-template-curly-in-string */
});

it("Correctly returns imports after a template expression", () => {
/* eslint-disable no-template-curly-in-string */
test("`${foo}`; import \"./foo\";",
Expand Down

0 comments on commit 8000332

Please sign in to comment.