Fix up code so we don't crash when TS itself is emitted with let/const (#50151)

This commit is contained in:
Jake Bailey
2022-08-10 16:38:38 -04:00
committed by GitHub
parent b56483feb8
commit 8a24fe75c9
2 changed files with 9 additions and 3 deletions

View File

@@ -27075,9 +27075,11 @@ namespace ts {
case AssignmentDeclarationKind.ExportsProperty:
case AssignmentDeclarationKind.Prototype:
case AssignmentDeclarationKind.PrototypeProperty:
let valueDeclaration = binaryExpression.left.symbol?.valueDeclaration;
// falls through
case AssignmentDeclarationKind.ModuleExports:
let valueDeclaration: Declaration | undefined;
if (kind !== AssignmentDeclarationKind.ModuleExports) {
valueDeclaration = binaryExpression.left.symbol?.valueDeclaration;
}
valueDeclaration ||= binaryExpression.symbol?.valueDeclaration;
const annotated = valueDeclaration && getEffectiveTypeAnnotationNode(valueDeclaration);
return annotated ? getTypeFromTypeNode(annotated) : undefined;