Skip to content

Commit a4c87df

Browse files
author
Benjamin Lichtman
committed
[WIP] Use original identifier name to count up from when renaming collisions
1 parent 7466ac1 commit a4c87df

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
@@ -240,7 +240,7 @@ namespace ts.codefix {
240240
}
241241

242242
function getNewNameIfConflict(name: Identifier, allVarNames: SymbolAndIdentifier[]): SynthIdentifier {
243-
const numVarsSameName = allVarNames.filter(elem => elem.identifier.text === name.text).length;
243+
const numVarsSameName = allVarNames.filter(elem => elem.symbol.name === name.text).length;
244244
const numberOfAssignmentsOriginal = 0;
245245
const identifier = numVarsSameName === 0 ? name : createIdentifier(name.text + "_" + numVarsSameName);
246246
return { identifier, types: [], numberOfAssignmentsOriginal };
@@ -426,7 +426,7 @@ namespace ts.codefix {
426426

427427
if (hasPrevArgName && !shouldReturn) {
428428
const type = transformer.checker.getTypeAtLocation(func);
429-
const returnType = getLastCallSignature(type, transformer.checker).getReturnType();
429+
const returnType = getLastCallSignature(type, transformer.checker)!.getReturnType();
430430
const varDeclOrAssignment = createVariableDeclarationOrAssignment(prevArgName!, getSynthesizedDeepClone(funcBody) as Expression, transformer);
431431
prevArgName!.types.push(returnType);
432432
return varDeclOrAssignment;
@@ -440,7 +440,7 @@ namespace ts.codefix {
440440
return createNodeArray([]);
441441
}
442442

443-
function getLastCallSignature(type: Type, checker: TypeChecker): Signature {
443+
function getLastCallSignature(type: Type, checker: TypeChecker): Signature | undefined {
444444
const callSignatures = type && checker.getSignaturesOfType(type, SignatureKind.Call);
445445
return callSignatures && callSignatures[callSignatures.length - 1];
446446
}

0 commit comments

Comments
 (0)