From d00a5c954f3a032226a7249e3e97f93bc9060986 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Sat, 11 Apr 2020 15:52:03 -0700 Subject: [PATCH] Add _0_is_declared_here pointing to accessor declaration --- src/compiler/checker.ts | 5 ++++- .../reference/accessorAccidentalCallDiagnostic.errors.txt | 1 + .../instancePropertiesInheritedIntoClassType.errors.txt | 2 ++ .../reference/instancePropertyInClassType.errors.txt | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 79a5d93f3b..a7d623cb56 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25856,7 +25856,10 @@ namespace ts { // Diagnose get accessors incorrectly called as functions const { resolvedSymbol } = getNodeLinks(node.expression); if (resolvedSymbol && resolvedSymbol.flags & SymbolFlags.GetAccessor) { - relatedInformation.push(createDiagnosticForNode(node.expression, Diagnostics._0_is_a_get_accessor_did_you_mean_to_use_it_without, getTextOfNode(node.expression))); + relatedInformation.push( + createDiagnosticForNode(node.expression, Diagnostics._0_is_a_get_accessor_did_you_mean_to_use_it_without, getTextOfNode(node.expression)), + createDiagnosticForNode(resolvedSymbol.valueDeclaration, Diagnostics._0_is_declared_here, symbolToString(resolvedSymbol)) + ); } } else if (node.arguments.length === 1) { diff --git a/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt b/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt index f2bf6b4cf1..50faf9dc98 100644 --- a/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt +++ b/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt @@ -13,5 +13,6 @@ tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): error TS2349: Th !!! error TS2349: This expression is not callable. !!! error TS2349: Type 'Number' has no call signatures. !!! related TS6232 tests/cases/compiler/accessorAccidentalCallDiagnostic.ts:6:12: 'x.property' is a 'get' accessor; did you mean to use it without '()'? +!!! related TS2728 tests/cases/compiler/accessorAccidentalCallDiagnostic.ts:3:9: 'property' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt index 33d34d8db6..87a2ec97a4 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt @@ -36,6 +36,7 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn !!! error TS2349: This expression is not callable. !!! error TS2349: Type 'Number' has no call signatures. !!! related TS6232 tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts:19:14: 'd.y' is a 'get' accessor; did you mean to use it without '()'? +!!! related TS2728 tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts:4:13: 'y' is declared here. } @@ -66,4 +67,5 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn !!! error TS2349: This expression is not callable. !!! error TS2349: Type 'String' has no call signatures. !!! related TS6232 tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts:41:14: 'd.y' is a 'get' accessor; did you mean to use it without '()'? +!!! related TS2728 tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts:26:13: 'y' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/instancePropertyInClassType.errors.txt b/tests/baselines/reference/instancePropertyInClassType.errors.txt index c09527fd12..f4bdd12925 100644 --- a/tests/baselines/reference/instancePropertyInClassType.errors.txt +++ b/tests/baselines/reference/instancePropertyInClassType.errors.txt @@ -34,6 +34,7 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t !!! error TS2349: This expression is not callable. !!! error TS2349: Type 'Number' has no call signatures. !!! related TS6232 tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts:17:14: 'c.y' is a 'get' accessor; did you mean to use it without '()'? +!!! related TS2728 tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts:4:13: 'y' is declared here. } @@ -62,4 +63,5 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t !!! error TS2349: This expression is not callable. !!! error TS2349: Type 'String' has no call signatures. !!! related TS6232 tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts:37:14: 'c.y' is a 'get' accessor; did you mean to use it without '()'? +!!! related TS2728 tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts:24:13: 'y' is declared here. } \ No newline at end of file