From 79f09dab4f6ea788c595692b7fa724ea8778abde Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 30 Oct 2015 09:14:39 -0700 Subject: [PATCH] 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. --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 99b3d97b7be..d1dbc966952 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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); } }