From 61f60057f1798cae92781a1f2d6521a5f378a1a1 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Sun, 5 Apr 2020 15:17:14 -0700 Subject: [PATCH 1/6] Better error message for accidental calls to get-accessors --- src/compiler/checker.ts | 19 +++++++++----- src/compiler/diagnosticMessages.json | 4 +++ ...ccessorAccidentalCallDiagnostic.errors.txt | 17 +++++++++++++ .../accessorAccidentalCallDiagnostic.js | 25 +++++++++++++++++++ .../accessorAccidentalCallDiagnostic.symbols | 19 ++++++++++++++ .../accessorAccidentalCallDiagnostic.types | 20 +++++++++++++++ ...ropertiesInheritedIntoClassType.errors.txt | 2 ++ .../instancePropertyInClassType.errors.txt | 2 ++ .../accessorAccidentalCallDiagnostic.ts | 9 +++++++ 9 files changed, 111 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt create mode 100644 tests/baselines/reference/accessorAccidentalCallDiagnostic.js create mode 100644 tests/baselines/reference/accessorAccidentalCallDiagnostic.symbols create mode 100644 tests/baselines/reference/accessorAccidentalCallDiagnostic.types create mode 100644 tests/cases/compiler/accessorAccidentalCallDiagnostic.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5cab127293b72..79a5d93f3bd86 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25851,14 +25851,21 @@ namespace ts { error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); } else { - let relatedInformation: DiagnosticRelatedInformation | undefined; - if (node.arguments.length === 1) { + const relatedInformation: DiagnosticRelatedInformation[] = []; + if (node.arguments.length === 0) { + // 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))); + } + } + else if (node.arguments.length === 1) { const text = getSourceFileOfNode(node).text; if (isLineBreak(text.charCodeAt(skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) { - relatedInformation = createDiagnosticForNode(node.expression, Diagnostics.Are_you_missing_a_semicolon); + relatedInformation.push(createDiagnosticForNode(node.expression, Diagnostics.Are_you_missing_a_semicolon)); } } - invocationError(node.expression, apparentType, SignatureKind.Call, relatedInformation); + invocationError(node.expression, apparentType, SignatureKind.Call, ...relatedInformation); } return resolveErrorCall(node); } @@ -26126,7 +26133,7 @@ namespace ts { relatedMessage: maybeMissingAwait ? Diagnostics.Did_you_forget_to_use_await : undefined, }; } - function invocationError(errorTarget: Node, apparentType: Type, kind: SignatureKind, relatedInformation?: DiagnosticRelatedInformation) { + function invocationError(errorTarget: Node, apparentType: Type, kind: SignatureKind, ...relatedInformation: DiagnosticRelatedInformation[]) { const { messageChain, relatedMessage: relatedInfo } = invocationErrorDetails(apparentType, kind); const diagnostic = createDiagnosticForNodeFromMessageChain(errorTarget, messageChain); if (relatedInfo) { @@ -26138,7 +26145,7 @@ namespace ts { diagnostic.length = length; } diagnostics.add(diagnostic); - invocationErrorRecovery(apparentType, kind, relatedInformation ? addRelatedInfo(diagnostic, relatedInformation) : diagnostic); + invocationErrorRecovery(apparentType, kind, addRelatedInfo(diagnostic, ...relatedInformation)); } function invocationErrorRecovery(apparentType: Type, kind: SignatureKind, diagnostic: Diagnostic) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 29bf61b2f752b..9046f05de636d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4384,6 +4384,10 @@ "category": "Error", "code": 6231 }, + "'{0}' is a 'get' accessor; did you mean to use it without '()'?": { + "category": "Message", + "code": 6232 + }, "Projects to reference": { "category": "Message", diff --git a/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt b/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt new file mode 100644 index 0000000000000..f2bf6b4cf1860 --- /dev/null +++ b/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): error TS2349: This expression is not callable. + Type 'Number' has no call signatures. + + +==== tests/cases/compiler/accessorAccidentalCallDiagnostic.ts (1 errors) ==== + // https://github.com/microsoft/TypeScript/issues/24554 + class Test24554 { + get property(): number { return 1; } + } + function test24554(x: Test24554) { + return x.property(); + ~~~~~~~~ +!!! 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 '()'? + } + \ No newline at end of file diff --git a/tests/baselines/reference/accessorAccidentalCallDiagnostic.js b/tests/baselines/reference/accessorAccidentalCallDiagnostic.js new file mode 100644 index 0000000000000..6d5ae04ad5220 --- /dev/null +++ b/tests/baselines/reference/accessorAccidentalCallDiagnostic.js @@ -0,0 +1,25 @@ +//// [accessorAccidentalCallDiagnostic.ts] +// https://github.com/microsoft/TypeScript/issues/24554 +class Test24554 { + get property(): number { return 1; } +} +function test24554(x: Test24554) { + return x.property(); +} + + +//// [accessorAccidentalCallDiagnostic.js] +// https://github.com/microsoft/TypeScript/issues/24554 +var Test24554 = /** @class */ (function () { + function Test24554() { + } + Object.defineProperty(Test24554.prototype, "property", { + get: function () { return 1; }, + enumerable: false, + configurable: true + }); + return Test24554; +}()); +function test24554(x) { + return x.property(); +} diff --git a/tests/baselines/reference/accessorAccidentalCallDiagnostic.symbols b/tests/baselines/reference/accessorAccidentalCallDiagnostic.symbols new file mode 100644 index 0000000000000..d60d466e4cd69 --- /dev/null +++ b/tests/baselines/reference/accessorAccidentalCallDiagnostic.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/accessorAccidentalCallDiagnostic.ts === +// https://github.com/microsoft/TypeScript/issues/24554 +class Test24554 { +>Test24554 : Symbol(Test24554, Decl(accessorAccidentalCallDiagnostic.ts, 0, 0)) + + get property(): number { return 1; } +>property : Symbol(Test24554.property, Decl(accessorAccidentalCallDiagnostic.ts, 1, 17)) +} +function test24554(x: Test24554) { +>test24554 : Symbol(test24554, Decl(accessorAccidentalCallDiagnostic.ts, 3, 1)) +>x : Symbol(x, Decl(accessorAccidentalCallDiagnostic.ts, 4, 19)) +>Test24554 : Symbol(Test24554, Decl(accessorAccidentalCallDiagnostic.ts, 0, 0)) + + return x.property(); +>x.property : Symbol(Test24554.property, Decl(accessorAccidentalCallDiagnostic.ts, 1, 17)) +>x : Symbol(x, Decl(accessorAccidentalCallDiagnostic.ts, 4, 19)) +>property : Symbol(Test24554.property, Decl(accessorAccidentalCallDiagnostic.ts, 1, 17)) +} + diff --git a/tests/baselines/reference/accessorAccidentalCallDiagnostic.types b/tests/baselines/reference/accessorAccidentalCallDiagnostic.types new file mode 100644 index 0000000000000..17a59da43c8e7 --- /dev/null +++ b/tests/baselines/reference/accessorAccidentalCallDiagnostic.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/accessorAccidentalCallDiagnostic.ts === +// https://github.com/microsoft/TypeScript/issues/24554 +class Test24554 { +>Test24554 : Test24554 + + get property(): number { return 1; } +>property : number +>1 : 1 +} +function test24554(x: Test24554) { +>test24554 : (x: Test24554) => any +>x : Test24554 + + return x.property(); +>x.property() : any +>x.property : number +>x : Test24554 +>property : number +} + diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt index 3b39bdc8e78ea..33d34d8db6ef9 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt @@ -35,6 +35,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 '()'? } @@ -64,4 +65,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 '()'? } \ No newline at end of file diff --git a/tests/baselines/reference/instancePropertyInClassType.errors.txt b/tests/baselines/reference/instancePropertyInClassType.errors.txt index aa5f4eaa8d6eb..c09527fd12312 100644 --- a/tests/baselines/reference/instancePropertyInClassType.errors.txt +++ b/tests/baselines/reference/instancePropertyInClassType.errors.txt @@ -33,6 +33,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 '()'? } @@ -60,4 +61,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 '()'? } \ No newline at end of file diff --git a/tests/cases/compiler/accessorAccidentalCallDiagnostic.ts b/tests/cases/compiler/accessorAccidentalCallDiagnostic.ts new file mode 100644 index 0000000000000..a616fabe8ab6f --- /dev/null +++ b/tests/cases/compiler/accessorAccidentalCallDiagnostic.ts @@ -0,0 +1,9 @@ +// @target: es5 + +// https://github.com/microsoft/TypeScript/issues/24554 +class Test24554 { + get property(): number { return 1; } +} +function test24554(x: Test24554) { + return x.property(); +} From d00a5c954f3a032226a7249e3e97f93bc9060986 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Sat, 11 Apr 2020 15:52:03 -0700 Subject: [PATCH 2/6] 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 79a5d93f3bd86..a7d623cb567dd 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 f2bf6b4cf1860..50faf9dc98dde 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 33d34d8db6ef9..87a2ec97a4f5a 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 c09527fd12312..f4bdd129256c2 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 From d00f2b53adb1dafbba33ac07227b21a62d4acb53 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Sat, 18 Apr 2020 21:23:31 -0700 Subject: [PATCH 3/6] replace the original not-callable error --- src/compiler/checker.ts | 41 ++++++++++--------- src/compiler/diagnosticMessages.json | 4 +- ...ccessorAccidentalCallDiagnostic.errors.txt | 7 +--- ...ropertiesInheritedIntoClassType.errors.txt | 14 ++----- .../instancePropertyInClassType.errors.txt | 14 ++----- 5 files changed, 33 insertions(+), 47 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a7d623cb567dd..543188c6f8560 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25851,24 +25851,14 @@ namespace ts { error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); } else { - const relatedInformation: DiagnosticRelatedInformation[] = []; - if (node.arguments.length === 0) { - // 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)), - createDiagnosticForNode(resolvedSymbol.valueDeclaration, Diagnostics._0_is_declared_here, symbolToString(resolvedSymbol)) - ); - } - } - else if (node.arguments.length === 1) { + let relatedInformation: DiagnosticRelatedInformation | undefined; + if (node.arguments.length === 1) { const text = getSourceFileOfNode(node).text; if (isLineBreak(text.charCodeAt(skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) { - relatedInformation.push(createDiagnosticForNode(node.expression, Diagnostics.Are_you_missing_a_semicolon)); + relatedInformation = createDiagnosticForNode(node.expression, Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, SignatureKind.Call, ...relatedInformation); + invocationError(node.expression, apparentType, SignatureKind.Call, relatedInformation); } return resolveErrorCall(node); } @@ -26136,11 +26126,22 @@ namespace ts { relatedMessage: maybeMissingAwait ? Diagnostics.Did_you_forget_to_use_await : undefined, }; } - function invocationError(errorTarget: Node, apparentType: Type, kind: SignatureKind, ...relatedInformation: DiagnosticRelatedInformation[]) { - const { messageChain, relatedMessage: relatedInfo } = invocationErrorDetails(apparentType, kind); - const diagnostic = createDiagnosticForNodeFromMessageChain(errorTarget, messageChain); - if (relatedInfo) { - addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo)); + function invocationError(errorTarget: Node, apparentType: Type, kind: SignatureKind, relatedInformation?: DiagnosticRelatedInformation) { + let diagnostic; + if (isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { + // Diagnose get accessors incorrectly called as functions + const { resolvedSymbol } = getNodeLinks(errorTarget); + if (resolvedSymbol && resolvedSymbol.flags & SymbolFlags.GetAccessor) { + diagnostic = createDiagnosticForNode(errorTarget, Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without); + addRelatedInfo(diagnostic, createDiagnosticForNode(resolvedSymbol.valueDeclaration, Diagnostics._0_is_declared_here, symbolToString(resolvedSymbol))); + } + } + if (!diagnostic) { + const { messageChain, relatedMessage: relatedInfo } = invocationErrorDetails(apparentType, kind); + diagnostic = createDiagnosticForNodeFromMessageChain(errorTarget, messageChain); + if (relatedInfo) { + addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo)); + } } if (isCallExpression(errorTarget.parent)) { const { start, length } = getDiagnosticSpanForCallNode(errorTarget.parent, /* doNotIncludeArguments */ true); @@ -26148,7 +26149,7 @@ namespace ts { diagnostic.length = length; } diagnostics.add(diagnostic); - invocationErrorRecovery(apparentType, kind, addRelatedInfo(diagnostic, ...relatedInformation)); + invocationErrorRecovery(apparentType, kind, relatedInformation ? addRelatedInfo(diagnostic, relatedInformation) : diagnostic); } function invocationErrorRecovery(apparentType: Type, kind: SignatureKind, diagnostic: Diagnostic) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9046f05de636d..9c1fa1adfa22f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4384,7 +4384,7 @@ "category": "Error", "code": 6231 }, - "'{0}' is a 'get' accessor; did you mean to use it without '()'?": { + "This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?": { "category": "Message", "code": 6232 }, @@ -5645,7 +5645,7 @@ "category": "Message", "code": 95116 }, - + "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": { "category": "Error", "code": 18004 diff --git a/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt b/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt index 50faf9dc98dde..f5e0afe4bdc70 100644 --- a/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt +++ b/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt @@ -1,5 +1,4 @@ -tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): error TS2349: This expression is not callable. - Type 'Number' has no call signatures. +tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? ==== tests/cases/compiler/accessorAccidentalCallDiagnostic.ts (1 errors) ==== @@ -10,9 +9,7 @@ tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): error TS2349: Th function test24554(x: Test24554) { return x.property(); ~~~~~~~~ -!!! 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 '()'? +!!! message TS6232: This expression is not callable because it 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 87a2ec97a4f5a..31190afaf0483 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt @@ -1,11 +1,9 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,16): error TS2349: This expression is not callable. - Type 'Number' has no call signatures. +tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,16): message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(26,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(29,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,16): error TS2349: This expression is not callable. - Type 'String' has no call signatures. +tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,16): message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? ==== tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts (6 errors) ==== @@ -33,9 +31,7 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn r.y = 4; var r6 = d.y(); // error ~ -!!! 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 '()'? +!!! message TS6232: This expression is not callable because it 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. } @@ -64,8 +60,6 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn r.y = ''; var r6 = d.y(); // error ~ -!!! 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 '()'? +!!! message TS6232: This expression is not callable because it 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 f4bdd129256c2..62241900abd83 100644 --- a/tests/baselines/reference/instancePropertyInClassType.errors.txt +++ b/tests/baselines/reference/instancePropertyInClassType.errors.txt @@ -1,11 +1,9 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,16): error TS2349: This expression is not callable. - Type 'Number' has no call signatures. +tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,16): message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(24,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(27,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,16): error TS2349: This expression is not callable. - Type 'String' has no call signatures. +tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,16): message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? ==== tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts (6 errors) ==== @@ -31,9 +29,7 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t r.y = 4; var r6 = c.y(); // error ~ -!!! 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 '()'? +!!! message TS6232: This expression is not callable because it 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. } @@ -60,8 +56,6 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t r.y = ''; var r6 = c.y(); // error ~ -!!! 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 '()'? +!!! message TS6232: This expression is not callable because it 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 From 6051fc1814e9344c5c0f35eec9bac325822ea23a Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Wed, 29 Apr 2020 22:58:18 -0700 Subject: [PATCH 4/6] move to invocationErrorDetails --- src/compiler/checker.ts | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 543188c6f8560..90f31841ab555 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -26049,7 +26049,7 @@ namespace ts { return true; } - function invocationErrorDetails(apparentType: Type, kind: SignatureKind): { messageChain: DiagnosticMessageChain, relatedMessage: DiagnosticMessage | undefined } { + function invocationErrorDetails(errorTarget: Node, apparentType: Type, kind: SignatureKind): { messageChain: DiagnosticMessageChain, relatedMessage: DiagnosticMessage | undefined } { let errorInfo: DiagnosticMessageChain | undefined; const isCall = kind === SignatureKind.Call; const awaitedType = getAwaitedType(apparentType); @@ -26118,6 +26118,15 @@ namespace ts { typeToString(apparentType) ); } + + // Diagnose get accessors incorrectly called as functions + if (isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { + const { resolvedSymbol } = getNodeLinks(errorTarget); + if (resolvedSymbol && resolvedSymbol.flags & SymbolFlags.GetAccessor) { + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without); + } + } + return { messageChain: chainDiagnosticMessages( errorInfo, @@ -26127,21 +26136,10 @@ namespace ts { }; } function invocationError(errorTarget: Node, apparentType: Type, kind: SignatureKind, relatedInformation?: DiagnosticRelatedInformation) { - let diagnostic; - if (isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { - // Diagnose get accessors incorrectly called as functions - const { resolvedSymbol } = getNodeLinks(errorTarget); - if (resolvedSymbol && resolvedSymbol.flags & SymbolFlags.GetAccessor) { - diagnostic = createDiagnosticForNode(errorTarget, Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without); - addRelatedInfo(diagnostic, createDiagnosticForNode(resolvedSymbol.valueDeclaration, Diagnostics._0_is_declared_here, symbolToString(resolvedSymbol))); - } - } - if (!diagnostic) { - const { messageChain, relatedMessage: relatedInfo } = invocationErrorDetails(apparentType, kind); - diagnostic = createDiagnosticForNodeFromMessageChain(errorTarget, messageChain); - if (relatedInfo) { - addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo)); - } + const { messageChain, relatedMessage: relatedInfo } = invocationErrorDetails(errorTarget, apparentType, kind); + const diagnostic = createDiagnosticForNodeFromMessageChain(errorTarget, messageChain); + if (relatedInfo) { + addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo)); } if (isCallExpression(errorTarget.parent)) { const { start, length } = getDiagnosticSpanForCallNode(errorTarget.parent, /* doNotIncludeArguments */ true); @@ -26242,7 +26240,7 @@ namespace ts { const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - const errorDetails = invocationErrorDetails(apparentType, SignatureKind.Call); + const errorDetails = invocationErrorDetails(node.expression, apparentType, SignatureKind.Call); const messageChain = chainDiagnosticMessages(errorDetails.messageChain, headMessage); const diag = createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { From 0b1cb745301e2582d6ba18fd3817d40f6d4b13a4 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Wed, 29 Apr 2020 23:04:24 -0700 Subject: [PATCH 5/6] fix order and tests --- src/compiler/checker.ts | 9 ++++----- .../accessorAccidentalCallDiagnostic.errors.txt | 7 ++++--- ...ancePropertiesInheritedIntoClassType.errors.txt | 14 ++++++++------ .../instancePropertyInClassType.errors.txt | 14 ++++++++------ 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 897654e3363b5..191764c92a3fd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -26324,19 +26324,18 @@ namespace ts { ); } + let headMessage = isCall ? Diagnostics.This_expression_is_not_callable : Diagnostics.This_expression_is_not_constructable; + // Diagnose get accessors incorrectly called as functions if (isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { const { resolvedSymbol } = getNodeLinks(errorTarget); if (resolvedSymbol && resolvedSymbol.flags & SymbolFlags.GetAccessor) { - errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without); + headMessage = Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } return { - messageChain: chainDiagnosticMessages( - errorInfo, - isCall ? Diagnostics.This_expression_is_not_callable : Diagnostics.This_expression_is_not_constructable - ), + messageChain: chainDiagnosticMessages(errorInfo, headMessage), relatedMessage: maybeMissingAwait ? Diagnostics.Did_you_forget_to_use_await : undefined, }; } diff --git a/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt b/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt index f5e0afe4bdc70..0b3e5df31ad9b 100644 --- a/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt +++ b/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt @@ -1,4 +1,5 @@ -tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? + Type 'Number' has no call signatures. ==== tests/cases/compiler/accessorAccidentalCallDiagnostic.ts (1 errors) ==== @@ -9,7 +10,7 @@ tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): message TS6232: function test24554(x: Test24554) { return x.property(); ~~~~~~~~ -!!! message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? -!!! related TS2728 tests/cases/compiler/accessorAccidentalCallDiagnostic.ts:3:9: 'property' is declared here. +!!! message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +!!! message TS6234: Type 'Number' has no call signatures. } \ No newline at end of file diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt index 31190afaf0483..fab7ccc6e5d6c 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt @@ -1,9 +1,11 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,16): message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,16): message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? + Type 'Number' has no call signatures. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(26,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(29,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,16): message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,16): message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? + Type 'String' has no call signatures. ==== tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts (6 errors) ==== @@ -31,8 +33,8 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn r.y = 4; var r6 = d.y(); // error ~ -!!! message TS6232: This expression is not callable because it 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. +!!! message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +!!! message TS6234: Type 'Number' has no call signatures. } @@ -60,6 +62,6 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn r.y = ''; var r6 = d.y(); // error ~ -!!! message TS6232: This expression is not callable because it 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. +!!! message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +!!! message TS6234: Type 'String' has no call signatures. } \ No newline at end of file diff --git a/tests/baselines/reference/instancePropertyInClassType.errors.txt b/tests/baselines/reference/instancePropertyInClassType.errors.txt index 62241900abd83..2921b37568102 100644 --- a/tests/baselines/reference/instancePropertyInClassType.errors.txt +++ b/tests/baselines/reference/instancePropertyInClassType.errors.txt @@ -1,9 +1,11 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,16): message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,16): message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? + Type 'Number' has no call signatures. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(24,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(27,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,16): message TS6232: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,16): message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? + Type 'String' has no call signatures. ==== tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts (6 errors) ==== @@ -29,8 +31,8 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t r.y = 4; var r6 = c.y(); // error ~ -!!! message TS6232: This expression is not callable because it 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. +!!! message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +!!! message TS6234: Type 'Number' has no call signatures. } @@ -56,6 +58,6 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t r.y = ''; var r6 = c.y(); // error ~ -!!! message TS6232: This expression is not callable because it 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. +!!! message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +!!! message TS6234: Type 'String' has no call signatures. } \ No newline at end of file From 0b531720d48e3ae67a3bda8d4c363324c2f6ac93 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 20 May 2020 16:53:17 -0700 Subject: [PATCH 6/6] Make new error an error, not message --- src/compiler/diagnosticMessages.json | 2 +- .../accessorAccidentalCallDiagnostic.errors.txt | 6 +++--- ...stancePropertiesInheritedIntoClassType.errors.txt | 12 ++++++------ .../reference/instancePropertyInClassType.errors.txt | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 362fb805a0e88..ef46447faacdb 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4417,7 +4417,7 @@ "code": 6233 }, "This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?": { - "category": "Message", + "category": "Error", "code": 6234 }, diff --git a/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt b/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt index 0b3e5df31ad9b..ee57be1742782 100644 --- a/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt +++ b/tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? Type 'Number' has no call signatures. @@ -10,7 +10,7 @@ tests/cases/compiler/accessorAccidentalCallDiagnostic.ts(6,14): message TS6234: function test24554(x: Test24554) { return x.property(); ~~~~~~~~ -!!! message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? -!!! message TS6234: Type 'Number' has no call signatures. +!!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +!!! error TS6234: Type 'Number' has no call signatures. } \ No newline at end of file diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt index fab7ccc6e5d6c..e7584c3d831a8 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt @@ -1,10 +1,10 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,16): message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,16): error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? Type 'Number' has no call signatures. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(26,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(29,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,16): message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,16): error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? Type 'String' has no call signatures. @@ -33,8 +33,8 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn r.y = 4; var r6 = d.y(); // error ~ -!!! message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? -!!! message TS6234: Type 'Number' has no call signatures. +!!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +!!! error TS6234: Type 'Number' has no call signatures. } @@ -62,6 +62,6 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn r.y = ''; var r6 = d.y(); // error ~ -!!! message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? -!!! message TS6234: Type 'String' has no call signatures. +!!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +!!! error TS6234: Type 'String' has no call signatures. } \ No newline at end of file diff --git a/tests/baselines/reference/instancePropertyInClassType.errors.txt b/tests/baselines/reference/instancePropertyInClassType.errors.txt index 2921b37568102..224290a4c001b 100644 --- a/tests/baselines/reference/instancePropertyInClassType.errors.txt +++ b/tests/baselines/reference/instancePropertyInClassType.errors.txt @@ -1,10 +1,10 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,16): message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,16): error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? Type 'Number' has no call signatures. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(24,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(27,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,16): message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,16): error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? Type 'String' has no call signatures. @@ -31,8 +31,8 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t r.y = 4; var r6 = c.y(); // error ~ -!!! message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? -!!! message TS6234: Type 'Number' has no call signatures. +!!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +!!! error TS6234: Type 'Number' has no call signatures. } @@ -58,6 +58,6 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t r.y = ''; var r6 = c.y(); // error ~ -!!! message TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? -!!! message TS6234: Type 'String' has no call signatures. +!!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? +!!! error TS6234: Type 'String' has no call signatures. } \ No newline at end of file