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.
This commit is contained in:
Nathan Shively-Sanders
2015-10-30 09:14:39 -07:00
parent 067e1ccef2
commit 79f09dab4f
+1 -1
View File
@@ -12647,7 +12647,7 @@ namespace ts {
error(node.expression, Diagnostics.Setters_cannot_return_a_value);
}
else if (func.kind === SyntaxKind.Constructor) {
if (!isTypeAssignableTo(exprType, returnType)) {
if (!checkTypeAssignableTo(exprType, returnType, node.expression)) {
error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
}
}