Skip to content

Commit 9d1b325

Browse files
committed
Update another test
1 parent f77cd8e commit 9d1b325

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(15,5): error TS7023: 'f' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
2+
tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(16,21): error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'.
3+
4+
5+
==== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts (2 errors) ====
6+
7+
class MyClass {
8+
t: number;
9+
10+
fn() {
11+
type ContainingThis = this;
12+
//type of 'this' in an object literal is the containing scope's this
13+
var t = { x: this, y: this.t };
14+
var t: { x: ContainingThis; y: number };
15+
}
16+
}
17+
18+
//type of 'this' in an object literal method is the type of the object literal
19+
var obj = {
20+
f() {
21+
~
22+
!!! error TS7023: 'f' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
23+
return this.spaaace;
24+
~~~~~~~
25+
!!! error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'.
26+
}
27+
};
28+
var obj: { f: () => any; };
29+

tests/baselines/reference/thisInObjectLiterals.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [thisInObjectLiterals.ts]
2+
23
class MyClass {
34
t: number;
45

tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// @noImplicitAny: true
2+
// @noImplicitThis: true
3+
14
class MyClass {
25
t: number;
36

0 commit comments

Comments
 (0)