Skip to content

Commit 42c9b47

Browse files
committed
Fix let/const selection for binding patterns
1 parent 06c8506 commit 42c9b47

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/services/codefixes/convertToAsyncFunction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ namespace ts.codefix {
196196
allVarNames.push({ identifier: synthName.identifier, symbol });
197197
addNameToFrequencyMap(collidingSymbolMap, ident.text, symbol);
198198
}
199-
// we only care about identifiers that are parameters and declarations (don't care about other uses)
200-
else if (node.parent && (isParameter(node.parent) || isVariableDeclaration(node.parent))) {
199+
// we only care about identifiers that are parameters, declarations, or binding elements (don't care about other uses)
200+
else if (node.parent && (isParameter(node.parent) || isVariableDeclaration(node.parent) || isBindingElement(node.parent))) {
201201
const originalName = node.text;
202202
const collidingSymbols = collidingSymbolMap.get(originalName);
203203

tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_arrayBindingPattern.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ function /*[#|*/f/*|]*/(): Promise<void>{
66
// ==ASYNC FUNCTION::Convert to async function==
77

88
async function f(): Promise<void>{
9-
let [result] = await fetch('https://typescriptlang.org');
9+
const [result] = await fetch('https://typescriptlang.org');
1010
console.log(result);
1111
}

tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_objectBindingPattern.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ function /*[#|*/f/*|]*/(): Promise<void>{
66
// ==ASYNC FUNCTION::Convert to async function==
77

88
async function f(): Promise<void>{
9-
let { result } = await fetch('https://typescriptlang.org');
9+
const { result } = await fetch('https://typescriptlang.org');
1010
console.log(result);
1111
}

0 commit comments

Comments
 (0)