Skip to content

Commit 225df9a

Browse files
committed
Fix #19257: Ensure a generated signature has a return type
1 parent 314172a commit 225df9a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/services/codefixes/inferFromUsage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ namespace ts.codefix {
636636
symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i]));
637637
parameters.push(symbol);
638638
}
639-
const returnType = getTypeFromUsageContext(callContext.returnType, checker);
639+
const returnType = getTypeFromUsageContext(callContext.returnType, checker) || checker.getVoidType();
640640
return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
641641
}
642642

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @noImplicitAny: true
4+
////function wat([|b |]) {
5+
//// b();
6+
////}
7+
8+
verify.rangeAfterCodeFix("b: () => void");

0 commit comments

Comments
 (0)