mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-16 07:13:43 -05:00
Bind the source file as external module only if not already done
Return type of require call is from external module resolution only if it doesnt resolve to local module Fixes #10931
This commit is contained in:
@@ -2000,7 +2000,9 @@ namespace ts {
|
||||
function setCommonJsModuleIndicator(node: Node) {
|
||||
if (!file.commonJsModuleIndicator) {
|
||||
file.commonJsModuleIndicator = node;
|
||||
bindSourceFileAsExternalModule();
|
||||
if (!file.externalModuleIndicator) {
|
||||
bindSourceFileAsExternalModule();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12535,7 +12535,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
// In JavaScript files, calls to any identifier 'require' are treated as external module imports
|
||||
if (isInJavaScriptFile(node) && isRequireCall(node, /*checkArgumentIsStringLiteral*/true)) {
|
||||
if (isInJavaScriptFile(node) &&
|
||||
isRequireCall(node, /*checkArgumentIsStringLiteral*/true) &&
|
||||
// Make sure require is not a local function
|
||||
!resolveName(node.expression, (<Identifier>node.expression).text, SymbolFlags.Value | SymbolFlags.ExportValue, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) {
|
||||
return resolveExternalModuleTypeByLiteral(<StringLiteral>node.arguments[0]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user