Skip to content

Commit a73b561

Browse files
author
Benjamin Lichtman
committed
Ensure name for callback is generated even when it has no args
1 parent 0995869 commit a73b561

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/services/codefixes/convertToAsyncFunction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ namespace ts.codefix {
172172

173173
// if the identifier refers to a function we want to add the new synthesized variable for the declaration (ex. blob in let blob = res(arg))
174174
// Note - the choice of the last call signature is arbitrary
175-
if (lastCallSignature && lastCallSignature.parameters.length && !synthNamesMap.has(symbolIdString)) {
176-
const firstParameter = lastCallSignature.parameters[0];
177-
const ident = isParameter(firstParameter.valueDeclaration) && tryCast(firstParameter.valueDeclaration.name, isIdentifier) || createOptimisticUniqueName("result");
175+
if (lastCallSignature && !synthNamesMap.has(symbolIdString)) {
176+
const firstParameter = firstOrUndefined(lastCallSignature.parameters);
177+
const ident = firstParameter && isParameter(firstParameter.valueDeclaration) && tryCast(firstParameter.valueDeclaration.name, isIdentifier) || createOptimisticUniqueName("result");
178178
const synthName = getNewNameIfConflict(ident, collidingSymbolMap);
179179
synthNamesMap.set(symbolIdString, synthName);
180180
allVarNames.push({ identifier: synthName.identifier, symbol });

0 commit comments

Comments
 (0)