fix(54982): "Inline variable" causes failure when variable is used as the initializer of a destructured variable declaration (#54988)

This commit is contained in:
Oleksandr T
2023-07-18 02:13:00 +03:00
committed by GitHub
parent 02e8d5ec61
commit f7a93c83ca
5 changed files with 44 additions and 1 deletions

View File

@@ -132,7 +132,7 @@ function getInliningInfo(file: SourceFile, startPosition: number, tryWithReferen
// If triggered in a variable declaration, make sure it's not in a catch clause or for-loop
// and that it has a value.
if (isInitializedVariable(parent) && isVariableDeclarationInVariableStatement(parent)) {
if (isInitializedVariable(parent) && isVariableDeclarationInVariableStatement(parent) && isIdentifier(parent.name)) {
// Don't inline the variable if it has multiple declarations.
if (checker.getMergedSymbol(parent.symbol).declarations?.length !== 1) {
return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };