Skip to content

Commit 79f09da

Browse files
committed
Add more detailed error message
When an object literal, for example, is returned that does not match the type of the consturctor, add detail about a field that is required but missing. Do this by passing `node.expression` instead of `undefined` -- the rest of the error reporting infrastructure is already in place.
1 parent 067e1cc commit 79f09da

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12647,7 +12647,7 @@ namespace ts {
1264712647
error(node.expression, Diagnostics.Setters_cannot_return_a_value);
1264812648
}
1264912649
else if (func.kind === SyntaxKind.Constructor) {
12650-
if (!isTypeAssignableTo(exprType, returnType)) {
12650+
if (!checkTypeAssignableTo(exprType, returnType, node.expression)) {
1265112651
error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
1265212652
}
1265312653
}

0 commit comments

Comments
 (0)