mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 11:43:18 -05:00
Fix commonjs require of ES export (#40221)
The commonjs-specific code for resolving access expressions on `require` assumes a fake commonjs export. For real exports, it needs to call resolveSymbol since it's outside the normal alias-resolving infrastructure.
This commit is contained in:
committed by
GitHub
parent
31fab0fb1e
commit
4aadd5af41
@@ -2412,7 +2412,7 @@ namespace ts {
|
||||
if (isVariableDeclaration(node) && node.initializer && isPropertyAccessExpression(node.initializer)) {
|
||||
const name = (getLeftmostPropertyAccessExpression(node.initializer.expression) as CallExpression).arguments[0] as StringLiteral;
|
||||
return isIdentifier(node.initializer.name)
|
||||
? getPropertyOfType(resolveExternalModuleTypeByLiteral(name), node.initializer.name.escapedText)
|
||||
? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), node.initializer.name.escapedText))
|
||||
: undefined;
|
||||
}
|
||||
if (isVariableDeclaration(node) || node.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
|
||||
|
||||
Reference in New Issue
Block a user