Skip to content

Commit 27154f8

Browse files
committed
Fixed a case related to commonjs export assignment
1 parent 398ab53 commit 27154f8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18448,7 +18448,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1844818448
}
1844918449

1845018450
function getESSymbolLikeTypeForNode(node: Node) {
18451-
const declaration = getValidESSymbolDeclaration(node)
18451+
const declaration = getValidESSymbolDeclaration(node);
1845218452
if (declaration) {
1845318453
const symbol = isCommonJsExportPropertyAssignment(declaration) ? getSymbolOfNode((declaration as BinaryExpression).left) : getSymbolOfNode(declaration);
1845418454
if (symbol) {

src/compiler/utilities.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,13 +2712,16 @@ export function isCommonJsExportPropertyAssignment(node: Node) {
27122712
/** @internal */
27132713
export function getValidESSymbolDeclaration(node: Node): Node | undefined {
27142714
while (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) {
2715+
if (isCommonJsExportPropertyAssignment(node)) {
2716+
return node;
2717+
}
27152718
node = node.parent;
27162719
}
2717-
if ((isVariableDeclaration(node) ? isVarConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
2720+
if (isVariableDeclaration(node) ? isVarConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
27182721
isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) :
2719-
isPropertySignature(node) && hasEffectiveReadonlyModifier(node)) || isCommonJsExportPropertyAssignment(node)) {
2722+
isPropertySignature(node) && hasEffectiveReadonlyModifier(node)) {
27202723
return node;
2721-
};
2724+
}
27222725
return undefined;
27232726
}
27242727

0 commit comments

Comments
 (0)