mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user