Skip to content

Commit 9394c5c

Browse files
committed
Add test for object literal methods
1 parent 22cc3a7 commit 9394c5c

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tests/cases/compiler/typeCheckReturnExpressionMethodBody.ts(1,13): error TS7010: 'bar', which lacks return-type annotation, implicitly has an 'any' return type.
2+
3+
4+
==== tests/cases/compiler/typeCheckReturnExpressionMethodBody.ts (1 errors) ====
5+
var foo = { bar() { return undefined } };
6+
~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
!!! error TS7010: 'bar', which lacks return-type annotation, implicitly has an 'any' return type.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//// [typeCheckReturnExpressionMethodBody.ts]
2+
var foo = { bar() { return undefined } };
3+
4+
//// [typeCheckReturnExpressionMethodBody.js]
5+
var foo = { bar: function () { return undefined; } };
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//@noImplicitAny: true
2+
var foo = { bar() { return undefined } };

0 commit comments

Comments
 (0)