47 lines
981 B
Text
47 lines
981 B
Text
=== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts ===
|
|
class MyClass {
|
|
>MyClass : MyClass
|
|
|
|
t: number;
|
|
>t : number
|
|
|
|
fn() {
|
|
>fn : () => void
|
|
|
|
//type of 'this' in an object literal is the containing scope's this
|
|
var t = { x: this, y: this.t };
|
|
>t : { x: MyClass; y: number; }
|
|
>{ x: this, y: this.t } : { x: MyClass; y: number; }
|
|
>x : MyClass
|
|
>this : MyClass
|
|
>y : number
|
|
>this.t : number
|
|
>this : MyClass
|
|
>t : number
|
|
|
|
var t: { x: MyClass; y: number };
|
|
>t : { x: MyClass; y: number; }
|
|
>x : MyClass
|
|
>MyClass : MyClass
|
|
>y : number
|
|
}
|
|
}
|
|
|
|
//type of 'this' in an object literal property of a function type is Any
|
|
var obj = {
|
|
>obj : { f(): any; }
|
|
>{ f() { return this.spaaace; }} : { f(): any; }
|
|
|
|
f() {
|
|
>f : () => any
|
|
|
|
return this.spaaace;
|
|
>this.spaaace : any
|
|
>this : any
|
|
>spaaace : any
|
|
}
|
|
};
|
|
var obj: { f: () => any; };
|
|
>obj : { f(): any; }
|
|
>f : () => any
|
|
|