1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
=== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts ===
interface I {
>I : Symbol(I, Decl(looseThisTypeInFunctions.ts, 0, 0))
n: number;
>n : Symbol(I.n, Decl(looseThisTypeInFunctions.ts, 0, 13))
explicitThis(this: this, m: number): number;
>explicitThis : Symbol(I.explicitThis, Decl(looseThisTypeInFunctions.ts, 1, 14))
>this : Symbol(this, Decl(looseThisTypeInFunctions.ts, 2, 17))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 2, 28))
}
interface Unused {
>Unused : Symbol(Unused, Decl(looseThisTypeInFunctions.ts, 3, 1))
implicitNoThis(m: number): number;
>implicitNoThis : Symbol(Unused.implicitNoThis, Decl(looseThisTypeInFunctions.ts, 4, 18))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 5, 19))
}
class C implements I {
>C : Symbol(C, Decl(looseThisTypeInFunctions.ts, 6, 1))
>I : Symbol(I, Decl(looseThisTypeInFunctions.ts, 0, 0))
n: number;
>n : Symbol(C.n, Decl(looseThisTypeInFunctions.ts, 7, 22))
explicitThis(this: this, m: number): number {
>explicitThis : Symbol(C.explicitThis, Decl(looseThisTypeInFunctions.ts, 8, 14))
>this : Symbol(this, Decl(looseThisTypeInFunctions.ts, 9, 17))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 9, 28))
return this.n + m;
>this.n : Symbol(C.n, Decl(looseThisTypeInFunctions.ts, 7, 22))
>this : Symbol(this, Decl(looseThisTypeInFunctions.ts, 9, 17))
>n : Symbol(C.n, Decl(looseThisTypeInFunctions.ts, 7, 22))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 9, 28))
}
implicitThis(m: number): number {
>implicitThis : Symbol(C.implicitThis, Decl(looseThisTypeInFunctions.ts, 11, 5))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 12, 17))
return this.n + m;
>this.n : Symbol(C.n, Decl(looseThisTypeInFunctions.ts, 7, 22))
>this : Symbol(C, Decl(looseThisTypeInFunctions.ts, 6, 1))
>n : Symbol(C.n, Decl(looseThisTypeInFunctions.ts, 7, 22))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 12, 17))
}
explicitVoid(this: void, m: number): number {
>explicitVoid : Symbol(C.explicitVoid, Decl(looseThisTypeInFunctions.ts, 14, 5))
>this : Symbol(this, Decl(looseThisTypeInFunctions.ts, 15, 17))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 15, 28))
return m + 1;
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 15, 28))
}
}
let c = new C();
>c : Symbol(c, Decl(looseThisTypeInFunctions.ts, 19, 3))
>C : Symbol(C, Decl(looseThisTypeInFunctions.ts, 6, 1))
c.explicitVoid = c.explicitThis; // error, 'void' is missing everything
>c.explicitVoid : Symbol(C.explicitVoid, Decl(looseThisTypeInFunctions.ts, 14, 5))
>c : Symbol(c, Decl(looseThisTypeInFunctions.ts, 19, 3))
>explicitVoid : Symbol(C.explicitVoid, Decl(looseThisTypeInFunctions.ts, 14, 5))
>c.explicitThis : Symbol(C.explicitThis, Decl(looseThisTypeInFunctions.ts, 8, 14))
>c : Symbol(c, Decl(looseThisTypeInFunctions.ts, 19, 3))
>explicitThis : Symbol(C.explicitThis, Decl(looseThisTypeInFunctions.ts, 8, 14))
let o = {
>o : Symbol(o, Decl(looseThisTypeInFunctions.ts, 21, 3))
n: 101,
>n : Symbol(n, Decl(looseThisTypeInFunctions.ts, 21, 9))
explicitThis: function (m: number) {
>explicitThis : Symbol(explicitThis, Decl(looseThisTypeInFunctions.ts, 22, 11))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 23, 28))
return m + this.n.length; // error, 'length' does not exist on 'number'
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 23, 28))
>this.n : Symbol(n, Decl(looseThisTypeInFunctions.ts, 21, 9))
>this : Symbol(o, Decl(looseThisTypeInFunctions.ts, 21, 7))
>n : Symbol(n, Decl(looseThisTypeInFunctions.ts, 21, 9))
},
implicitThis(m: number): number { return m; }
>implicitThis : Symbol(implicitThis, Decl(looseThisTypeInFunctions.ts, 25, 6))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 26, 17))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 26, 17))
};
let i: I = o;
>i : Symbol(i, Decl(looseThisTypeInFunctions.ts, 28, 3))
>I : Symbol(I, Decl(looseThisTypeInFunctions.ts, 0, 0))
>o : Symbol(o, Decl(looseThisTypeInFunctions.ts, 21, 3))
let o2: I = {
>o2 : Symbol(o2, Decl(looseThisTypeInFunctions.ts, 29, 3))
>I : Symbol(I, Decl(looseThisTypeInFunctions.ts, 0, 0))
n: 1001,
>n : Symbol(n, Decl(looseThisTypeInFunctions.ts, 29, 13))
explicitThis: function (m) {
>explicitThis : Symbol(explicitThis, Decl(looseThisTypeInFunctions.ts, 30, 12))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 31, 28))
return m + this.n.length; // error, this.n: number, no member 'length'
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 31, 28))
>this.n : Symbol(I.n, Decl(looseThisTypeInFunctions.ts, 0, 13))
>this : Symbol(this, Decl(looseThisTypeInFunctions.ts, 2, 17))
>n : Symbol(I.n, Decl(looseThisTypeInFunctions.ts, 0, 13))
},
}
let x = i.explicitThis;
>x : Symbol(x, Decl(looseThisTypeInFunctions.ts, 35, 3))
>i.explicitThis : Symbol(I.explicitThis, Decl(looseThisTypeInFunctions.ts, 1, 14))
>i : Symbol(i, Decl(looseThisTypeInFunctions.ts, 28, 3))
>explicitThis : Symbol(I.explicitThis, Decl(looseThisTypeInFunctions.ts, 1, 14))
let n = x(12); // callee:void doesn't match this:I
>n : Symbol(n, Decl(looseThisTypeInFunctions.ts, 36, 3))
>x : Symbol(x, Decl(looseThisTypeInFunctions.ts, 35, 3))
let u: Unused;
>u : Symbol(u, Decl(looseThisTypeInFunctions.ts, 37, 3))
>Unused : Symbol(Unused, Decl(looseThisTypeInFunctions.ts, 3, 1))
let y = u.implicitNoThis;
>y : Symbol(y, Decl(looseThisTypeInFunctions.ts, 38, 3))
>u.implicitNoThis : Symbol(Unused.implicitNoThis, Decl(looseThisTypeInFunctions.ts, 4, 18))
>u : Symbol(u, Decl(looseThisTypeInFunctions.ts, 37, 3))
>implicitNoThis : Symbol(Unused.implicitNoThis, Decl(looseThisTypeInFunctions.ts, 4, 18))
n = y(12); // ok, callee:void matches this:any
>n : Symbol(n, Decl(looseThisTypeInFunctions.ts, 36, 3))
>y : Symbol(y, Decl(looseThisTypeInFunctions.ts, 38, 3))
c.explicitVoid = c.implicitThis // ok, implicitThis(this:any)
>c.explicitVoid : Symbol(C.explicitVoid, Decl(looseThisTypeInFunctions.ts, 14, 5))
>c : Symbol(c, Decl(looseThisTypeInFunctions.ts, 19, 3))
>explicitVoid : Symbol(C.explicitVoid, Decl(looseThisTypeInFunctions.ts, 14, 5))
>c.implicitThis : Symbol(C.implicitThis, Decl(looseThisTypeInFunctions.ts, 11, 5))
>c : Symbol(c, Decl(looseThisTypeInFunctions.ts, 19, 3))
>implicitThis : Symbol(C.implicitThis, Decl(looseThisTypeInFunctions.ts, 11, 5))
o.implicitThis = c.implicitThis; // ok, implicitThis(this:any)
>o.implicitThis : Symbol(implicitThis, Decl(looseThisTypeInFunctions.ts, 25, 6))
>o : Symbol(o, Decl(looseThisTypeInFunctions.ts, 21, 3))
>implicitThis : Symbol(implicitThis, Decl(looseThisTypeInFunctions.ts, 25, 6))
>c.implicitThis : Symbol(C.implicitThis, Decl(looseThisTypeInFunctions.ts, 11, 5))
>c : Symbol(c, Decl(looseThisTypeInFunctions.ts, 19, 3))
>implicitThis : Symbol(C.implicitThis, Decl(looseThisTypeInFunctions.ts, 11, 5))
o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this)
>o.implicitThis : Symbol(implicitThis, Decl(looseThisTypeInFunctions.ts, 25, 6))
>o : Symbol(o, Decl(looseThisTypeInFunctions.ts, 21, 3))
>implicitThis : Symbol(implicitThis, Decl(looseThisTypeInFunctions.ts, 25, 6))
>c.explicitThis : Symbol(C.explicitThis, Decl(looseThisTypeInFunctions.ts, 8, 14))
>c : Symbol(c, Decl(looseThisTypeInFunctions.ts, 19, 3))
>explicitThis : Symbol(C.explicitThis, Decl(looseThisTypeInFunctions.ts, 8, 14))
o.implicitThis = i.explicitThis;
>o.implicitThis : Symbol(implicitThis, Decl(looseThisTypeInFunctions.ts, 25, 6))
>o : Symbol(o, Decl(looseThisTypeInFunctions.ts, 21, 3))
>implicitThis : Symbol(implicitThis, Decl(looseThisTypeInFunctions.ts, 25, 6))
>i.explicitThis : Symbol(I.explicitThis, Decl(looseThisTypeInFunctions.ts, 1, 14))
>i : Symbol(i, Decl(looseThisTypeInFunctions.ts, 28, 3))
>explicitThis : Symbol(I.explicitThis, Decl(looseThisTypeInFunctions.ts, 1, 14))
i.explicitThis = function(m) {
>i.explicitThis : Symbol(I.explicitThis, Decl(looseThisTypeInFunctions.ts, 1, 14))
>i : Symbol(i, Decl(looseThisTypeInFunctions.ts, 28, 3))
>explicitThis : Symbol(I.explicitThis, Decl(looseThisTypeInFunctions.ts, 1, 14))
>m : Symbol(m, Decl(looseThisTypeInFunctions.ts, 44, 26))
return this.n.length; // error, this.n: number
>this.n : Symbol(I.n, Decl(looseThisTypeInFunctions.ts, 0, 13))
>this : Symbol(this, Decl(looseThisTypeInFunctions.ts, 2, 17))
>n : Symbol(I.n, Decl(looseThisTypeInFunctions.ts, 0, 13))
}
|