@@ -4548,7 +4548,7 @@ namespace ts {
45484548 * @param target The right-hand-side of the relation.
45494549 * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'.
45504550 * Used as both to determine which checks are performed and as a cache of previously computed results.
4551- * @param errorNode The node upon which all errors will be reported, if defined.
4551+ * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used .
45524552 * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used.
45534553 * @param containingMessageChain A chain of errors to prepend any new errors found.
45544554 */
@@ -4593,16 +4593,6 @@ namespace ts {
45934593 }
45944594 return result !== Ternary.False;
45954595
4596- function reportErrorAndTryImproveErrorNode(
4597- newErrorNode: Node,
4598- message: DiagnosticMessage,
4599- arg0?: string,
4600- arg1?: string,
4601- arg2?: string) {
4602- errorNode = newErrorNode || errorNode;
4603- reportError(message, arg0, arg1, arg2);
4604- }
4605-
46064596 function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void {
46074597 errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2);
46084598 }
@@ -4777,11 +4767,13 @@ namespace ts {
47774767 for (let prop of getPropertiesOfObjectType(source)) {
47784768 if (!isKnownProperty(target, prop.name)) {
47794769 if (reportErrors) {
4780- reportErrorAndTryImproveErrorNode(
4781- prop.valueDeclaration,
4782- Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
4783- symbolToString(prop),
4784- typeToString(target));
4770+ // We know *exactly* where things went wrong when comparing the types.
4771+ // Use this property as the error node as this will be more helpful in
4772+ // reasoning about what went wrong.
4773+ errorNode = prop.valueDeclaration
4774+ reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
4775+ symbolToString(prop),
4776+ typeToString(target));
47854777 }
47864778 return true;
47874779 }
0 commit comments