Skip to content

Commit

Permalink
Do not resolve require calls in typescript files even if it contains …
Browse files Browse the repository at this point in the history
…dynamic import

Fixes #38611
  • Loading branch information
sheetalkamat committed Jul 15, 2020
1 parent 913ee19 commit 1f95af0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2176,7 +2176,7 @@ namespace ts {
const r = /import|require/g;
while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null
const node = getNodeAtPosition(file, r.lastIndex);
if (isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) {
if (isJavaScriptFile && isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) {
imports = append(imports, node.arguments[0]);
}
// we have to check the argument list has length of 1. We will still have to process these even though we have parsing error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,5 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/other', target file type 'TypeScript'.",
"File '/other.ts' exist - use it as a name resolution result.",
"======== Module name './other' was successfully resolved to '/other.ts'. ========",
"======== Resolving module '../outside-of-rootdir/foo' from '/index.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/outside-of-rootdir/foo', target file type 'TypeScript'.",
"Directory '/outside-of-rootdir' does not exist, skipping all lookups in it.",
"Loading module as file / folder, candidate module location '/outside-of-rootdir/foo', target file type 'JavaScript'.",
"Directory '/outside-of-rootdir' does not exist, skipping all lookups in it.",
"======== Module name '../outside-of-rootdir/foo' was not resolved. ========"
"======== Module name './other' was successfully resolved to '/other.ts'. ========"
]

0 comments on commit 1f95af0

Please sign in to comment.