Skip to content

Commit d00a5c9

Browse files
committed
Add _0_is_declared_here pointing to accessor declaration
1 parent 61f6005 commit d00a5c9

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25856,7 +25856,10 @@ namespace ts {
2585625856
// Diagnose get accessors incorrectly called as functions
2585725857
const { resolvedSymbol } = getNodeLinks(node.expression);
2585825858
if (resolvedSymbol && resolvedSymbol.flags & SymbolFlags.GetAccessor) {
25859-
relatedInformation.push(createDiagnosticForNode(node.expression, Diagnostics._0_is_a_get_accessor_did_you_mean_to_use_it_without, getTextOfNode(node.expression)));
25859+
relatedInformation.push(
25860+
createDiagnosticForNode(node.expression, Diagnostics._0_is_a_get_accessor_did_you_mean_to_use_it_without, getTextOfNode(node.expression)),
25861+
createDiagnosticForNode(resolvedSymbol.valueDeclaration, Diagnostics._0_is_declared_here, symbolToString(resolvedSymbol))
25862+
);
2586025863
}
2586125864
}
2586225865
else if (node.arguments.length === 1) {

tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): error TS2349: Th
1313
!!! error TS2349: This expression is not callable.
1414
!!! error TS2349: Type 'Number' has no call signatures.
1515
!!! related TS6232 tests/cases/compiler/accessorAccidentalCallDiagnostic.ts:6:12: 'x.property' is a 'get' accessor; did you mean to use it without '()'?
16+
!!! related TS2728 tests/cases/compiler/accessorAccidentalCallDiagnostic.ts:3:9: 'property' is declared here.
1617
}
1718

tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn
3636
!!! error TS2349: This expression is not callable.
3737
!!! error TS2349: Type 'Number' has no call signatures.
3838
!!! 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 '()'?
39+
!!! related TS2728 tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts:4:13: 'y' is declared here.
3940

4041
}
4142

@@ -66,4 +67,5 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn
6667
!!! error TS2349: This expression is not callable.
6768
!!! error TS2349: Type 'String' has no call signatures.
6869
!!! 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 '()'?
70+
!!! related TS2728 tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts:26:13: 'y' is declared here.
6971
}

tests/baselines/reference/instancePropertyInClassType.errors.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t
3434
!!! error TS2349: This expression is not callable.
3535
!!! error TS2349: Type 'Number' has no call signatures.
3636
!!! 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 '()'?
37+
!!! related TS2728 tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts:4:13: 'y' is declared here.
3738

3839
}
3940

@@ -62,4 +63,5 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t
6263
!!! error TS2349: This expression is not callable.
6364
!!! error TS2349: Type 'String' has no call signatures.
6465
!!! 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 '()'?
66+
!!! related TS2728 tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts:24:13: 'y' is declared here.
6567
}

0 commit comments

Comments
 (0)