Skip to content

Commit 33f6fa8

Browse files
Error on the return statement itself when checking against function return types.
1 parent d86d850 commit 33f6fa8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17922,27 +17922,27 @@ namespace ts {
1792217922

1792317923
if (func.kind === SyntaxKind.SetAccessor) {
1792417924
if (node.expression) {
17925-
error(node.expression, Diagnostics.Setters_cannot_return_a_value);
17925+
error(node, Diagnostics.Setters_cannot_return_a_value);
1792617926
}
1792717927
}
1792817928
else if (func.kind === SyntaxKind.Constructor) {
17929-
if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) {
17930-
error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
17929+
if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) {
17930+
error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
1793117931
}
1793217932
}
1793317933
else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) {
1793417934
if (isAsyncFunctionLike(func)) {
1793517935
const promisedType = getPromisedType(returnType);
17936-
const awaitedType = checkAwaitedType(exprType, node.expression || node, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
17936+
const awaitedType = checkAwaitedType(exprType, node, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
1793717937
if (promisedType) {
1793817938
// If the function has a return type, but promisedType is
1793917939
// undefined, an error will be reported in checkAsyncFunctionReturnType
1794017940
// so we don't need to report one here.
17941-
checkTypeAssignableTo(awaitedType, promisedType, node.expression || node);
17941+
checkTypeAssignableTo(awaitedType, promisedType, node);
1794217942
}
1794317943
}
1794417944
else {
17945-
checkTypeAssignableTo(exprType, returnType, node.expression || node);
17945+
checkTypeAssignableTo(exprType, returnType, node);
1794617946
}
1794717947
}
1794817948
}

0 commit comments

Comments
 (0)