TypeScript/tests/baselines/reference/typeOfThisGeneral.types
Nathan Shively-Sanders 580bb066c1
Make files safe for Windows (#44651)
* make typeofthis tests case-insensitive-safe

* shorten test case names

* correct way to change test directories

* update baselines
2021-06-18 09:06:51 -07:00

485 lines
11 KiB
Plaintext

=== tests/cases/conformance/expressions/thisKeyword/typeOfThisGeneral.ts ===
class MyTestClass {
>MyTestClass : MyTestClass
private canary: number;
>canary : number
static staticCanary: number;
>staticCanary : number
constructor() {
//type of 'this' in constructor body is the class instance type
var p = this.canary;
>p : number
>this.canary : number
>this : this
>canary : number
var p: number;
>p : number
this.canary = 3;
>this.canary = 3 : 3
>this.canary : number
>this : this
>canary : number
>3 : 3
}
//type of 'this' in member function param list is the class instance type
memberFunc(t = this) {
>memberFunc : (t?: this) => void
>t : this
>this : this
var t: MyTestClass;
>t : this
//type of 'this' in member function body is the class instance type
var p = this;
>p : this
>this : this
var p: MyTestClass;
>p : this
}
//type of 'this' in member accessor(get and set) body is the class instance type
get prop() {
>prop : this
var p = this;
>p : this
>this : this
var p: MyTestClass;
>p : this
return this;
>this : this
}
set prop(v) {
>prop : this
>v : this
var p = this;
>p : this
>this : this
var p: MyTestClass;
>p : this
p = v;
>p = v : this
>p : this
>v : this
v = p;
>v = p : this
>v : this
>p : this
}
someFunc = () => {
>someFunc : () => void
>() => { //type of 'this' in member variable initializer is the class instance type var t = this; var t: MyTestClass; } : () => void
//type of 'this' in member variable initializer is the class instance type
var t = this;
>t : this
>this : this
var t: MyTestClass;
>t : this
};
//type of 'this' in static function param list is constructor function type
static staticFn(t = this) {
>staticFn : (t?: typeof MyTestClass) => void
>t : typeof MyTestClass
>this : typeof MyTestClass
var t: typeof MyTestClass;
>t : typeof MyTestClass
>MyTestClass : typeof MyTestClass
var t = MyTestClass;
>t : typeof MyTestClass
>MyTestClass : typeof MyTestClass
t.staticCanary;
>t.staticCanary : number
>t : typeof MyTestClass
>staticCanary : number
//type of 'this' in static function body is constructor function type
var p = this;
>p : typeof MyTestClass
>this : typeof MyTestClass
var p: typeof MyTestClass;
>p : typeof MyTestClass
>MyTestClass : typeof MyTestClass
var p = MyTestClass;
>p : typeof MyTestClass
>MyTestClass : typeof MyTestClass
p.staticCanary;
>p.staticCanary : number
>p : typeof MyTestClass
>staticCanary : number
}
static get staticProp() {
>staticProp : typeof MyTestClass
//type of 'this' in static accessor body is constructor function type
var p = this;
>p : typeof MyTestClass
>this : typeof MyTestClass
var p: typeof MyTestClass;
>p : typeof MyTestClass
>MyTestClass : typeof MyTestClass
var p = MyTestClass;
>p : typeof MyTestClass
>MyTestClass : typeof MyTestClass
p.staticCanary;
>p.staticCanary : number
>p : typeof MyTestClass
>staticCanary : number
return this;
>this : typeof MyTestClass
}
static set staticProp(v: typeof MyTestClass) {
>staticProp : typeof MyTestClass
>v : typeof MyTestClass
>MyTestClass : typeof MyTestClass
//type of 'this' in static accessor body is constructor function type
var p = this;
>p : typeof MyTestClass
>this : typeof MyTestClass
var p: typeof MyTestClass;
>p : typeof MyTestClass
>MyTestClass : typeof MyTestClass
var p = MyTestClass;
>p : typeof MyTestClass
>MyTestClass : typeof MyTestClass
p.staticCanary;
>p.staticCanary : number
>p : typeof MyTestClass
>staticCanary : number
}
}
class MyGenericTestClass<T, U> {
>MyGenericTestClass : MyGenericTestClass<T, U>
private canary: number;
>canary : number
static staticCanary: number;
>staticCanary : number
constructor() {
//type of 'this' in constructor body is the class instance type
var p = this.canary;
>p : number
>this.canary : number
>this : this
>canary : number
var p: number;
>p : number
this.canary = 3;
>this.canary = 3 : 3
>this.canary : number
>this : this
>canary : number
>3 : 3
}
//type of 'this' in member function param list is the class instance type
memberFunc(t = this) {
>memberFunc : (t?: this) => void
>t : this
>this : this
var t: MyGenericTestClass<T, U>;
>t : this
//type of 'this' in member function body is the class instance type
var p = this;
>p : this
>this : this
var p: MyGenericTestClass<T, U>;
>p : this
}
//type of 'this' in member accessor(get and set) body is the class instance type
get prop() {
>prop : this
var p = this;
>p : this
>this : this
var p: MyGenericTestClass<T, U>;
>p : this
return this;
>this : this
}
set prop(v) {
>prop : this
>v : this
var p = this;
>p : this
>this : this
var p: MyGenericTestClass<T, U>;
>p : this
p = v;
>p = v : this
>p : this
>v : this
v = p;
>v = p : this
>v : this
>p : this
}
someFunc = () => {
>someFunc : () => void
>() => { //type of 'this' in member variable initializer is the class instance type var t = this; var t: MyGenericTestClass<T, U>; } : () => void
//type of 'this' in member variable initializer is the class instance type
var t = this;
>t : this
>this : this
var t: MyGenericTestClass<T, U>;
>t : this
};
//type of 'this' in static function param list is constructor function type
static staticFn(t = this) {
>staticFn : (t?: typeof MyGenericTestClass) => void
>t : typeof MyGenericTestClass
>this : typeof MyGenericTestClass
var t: typeof MyGenericTestClass;
>t : typeof MyGenericTestClass
>MyGenericTestClass : typeof MyGenericTestClass
var t = MyGenericTestClass;
>t : typeof MyGenericTestClass
>MyGenericTestClass : typeof MyGenericTestClass
t.staticCanary;
>t.staticCanary : number
>t : typeof MyGenericTestClass
>staticCanary : number
//type of 'this' in static function body is constructor function type
var p = this;
>p : typeof MyGenericTestClass
>this : typeof MyGenericTestClass
var p: typeof MyGenericTestClass;
>p : typeof MyGenericTestClass
>MyGenericTestClass : typeof MyGenericTestClass
var p = MyGenericTestClass;
>p : typeof MyGenericTestClass
>MyGenericTestClass : typeof MyGenericTestClass
p.staticCanary;
>p.staticCanary : number
>p : typeof MyGenericTestClass
>staticCanary : number
}
static get staticProp() {
>staticProp : typeof MyGenericTestClass
//type of 'this' in static accessor body is constructor function type
var p = this;
>p : typeof MyGenericTestClass
>this : typeof MyGenericTestClass
var p: typeof MyGenericTestClass;
>p : typeof MyGenericTestClass
>MyGenericTestClass : typeof MyGenericTestClass
var p = MyGenericTestClass;
>p : typeof MyGenericTestClass
>MyGenericTestClass : typeof MyGenericTestClass
p.staticCanary;
>p.staticCanary : number
>p : typeof MyGenericTestClass
>staticCanary : number
return this;
>this : typeof MyGenericTestClass
}
static set staticProp(v: typeof MyGenericTestClass) {
>staticProp : typeof MyGenericTestClass
>v : typeof MyGenericTestClass
>MyGenericTestClass : typeof MyGenericTestClass
//type of 'this' in static accessor body is constructor function type
var p = this;
>p : typeof MyGenericTestClass
>this : typeof MyGenericTestClass
var p: typeof MyGenericTestClass;
>p : typeof MyGenericTestClass
>MyGenericTestClass : typeof MyGenericTestClass
var p = MyGenericTestClass;
>p : typeof MyGenericTestClass
>MyGenericTestClass : typeof MyGenericTestClass
p.staticCanary;
>p.staticCanary : number
>p : typeof MyGenericTestClass
>staticCanary : number
}
}
//type of 'this' in a function declaration param list is Any
function fn(s = this) {
>fn : (s?: any) => void
>s : any
>this : any
var s: any;
>s : any
s.spaaaaaaace = 4;
>s.spaaaaaaace = 4 : 4
>s.spaaaaaaace : any
>s : any
>spaaaaaaace : any
>4 : 4
//type of 'this' in a function declaration body is Any
var t: any;
>t : any
var t = this;
>t : any
>this : any
this.spaaaaace = 4;
>this.spaaaaace = 4 : 4
>this.spaaaaace : any
>this : any
>spaaaaace : any
>4 : 4
}
//type of 'this' in a function expression param list list is Any
var q1 = function (s = this) {
>q1 : (s?: any) => void
>function (s = this) { var s: any; s.spaaaaaaace = 4; //type of 'this' in a function expression body is Any var t: any; var t = this; this.spaaaaace = 4;} : (s?: any) => void
>s : any
>this : any
var s: any;
>s : any
s.spaaaaaaace = 4;
>s.spaaaaaaace = 4 : 4
>s.spaaaaaaace : any
>s : any
>spaaaaaaace : any
>4 : 4
//type of 'this' in a function expression body is Any
var t: any;
>t : any
var t = this;
>t : any
>this : any
this.spaaaaace = 4;
>this.spaaaaace = 4 : 4
>this.spaaaaace : any
>this : any
>spaaaaace : any
>4 : 4
}
//type of 'this' in a fat arrow expression param list is typeof globalThis
var q2 = (s = this) => {
>q2 : (s?: typeof globalThis) => void
>(s = this) => { var s: typeof globalThis; s.spaaaaaaace = 4; //type of 'this' in a fat arrow expression body is typeof globalThis var t: typeof globalThis; var t = this; this.spaaaaace = 4;} : (s?: typeof globalThis) => void
>s : typeof globalThis
>this : typeof globalThis
var s: typeof globalThis;
>s : typeof globalThis
>globalThis : typeof globalThis
s.spaaaaaaace = 4;
>s.spaaaaaaace = 4 : 4
>s.spaaaaaaace : any
>s : typeof globalThis
>spaaaaaaace : any
>4 : 4
//type of 'this' in a fat arrow expression body is typeof globalThis
var t: typeof globalThis;
>t : typeof globalThis
>globalThis : typeof globalThis
var t = this;
>t : typeof globalThis
>this : typeof globalThis
this.spaaaaace = 4;
>this.spaaaaace = 4 : 4
>this.spaaaaace : any
>this : typeof globalThis
>spaaaaace : any
>4 : 4
}
//type of 'this' in global module is GlobalThis
var t: typeof globalThis;
>t : typeof globalThis
>globalThis : typeof globalThis
var t = this;
>t : typeof globalThis
>this : typeof globalThis
this.spaaaaace = 4;
>this.spaaaaace = 4 : 4
>this.spaaaaace : any
>this : typeof globalThis
>spaaaaace : any
>4 : 4