-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better error message for accidental calls to get-accessors
- Loading branch information
Showing
9 changed files
with
111 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/accessorAccidentalCallDiagnostic.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 '()'? | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/accessorAccidentalCallDiagnostic.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/accessorAccidentalCallDiagnostic.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/accessorAccidentalCallDiagnostic.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |