mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fix up code so we don't crash when TS itself is emitted with let/const (#50151)
This commit is contained in:
parent
b56483feb8
commit
8a24fe75c9
@ -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;
|
||||
|
||||
@ -1363,6 +1363,11 @@ namespace ts {
|
||||
onUnRecoverableConfigFileDiagnostic: noop,
|
||||
};
|
||||
|
||||
// The call to isProgramUptoDate below may refer back to documentRegistryBucketKey;
|
||||
// calculate this early so it's not undefined if downleveled to a var (or, if emitted
|
||||
// as a const variable without downleveling, doesn't crash).
|
||||
const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
|
||||
|
||||
// If the program is already up-to-date, we can reuse it
|
||||
if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), fileName => compilerHost!.fileExists(fileName), hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
||||
return;
|
||||
@ -1374,7 +1379,6 @@ namespace ts {
|
||||
// the program points to old source files that have been invalidated because of
|
||||
// incremental parsing.
|
||||
|
||||
const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
|
||||
const options: CreateProgramOptions = {
|
||||
rootNames: rootFileNames,
|
||||
options: newSettings,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user