mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
fix(51072): ts.preProcessFile finds import in template string after conditional expression with template strings (#51082)
This commit is contained in:
parent
ad56b5ca56
commit
d0bfd8caed
@ -347,8 +347,8 @@ namespace ts {
|
||||
|
||||
if (scanner.getToken() === SyntaxKind.TemplateHead) {
|
||||
const stack = [scanner.getToken()];
|
||||
let token = scanner.scan();
|
||||
loop: while (length(stack)) {
|
||||
const token = scanner.scan();
|
||||
switch (token) {
|
||||
case SyntaxKind.EndOfFileToken:
|
||||
break loop;
|
||||
@ -376,7 +376,6 @@ namespace ts {
|
||||
}
|
||||
break;
|
||||
}
|
||||
token = scanner.scan();
|
||||
}
|
||||
nextToken();
|
||||
}
|
||||
|
||||
@ -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\";",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user