|
| 1 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(1,9): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 2 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(2,14): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 3 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(3,9): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 4 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(5,16): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 5 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(5,23): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 6 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(6,12): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 7 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(11,13): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 8 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(12,14): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 9 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(13,18): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 10 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(14,23): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 11 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(15,15): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 12 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(15,22): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 13 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(19,13): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 14 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(20,14): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 15 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(21,18): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 16 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(22,23): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 17 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(23,15): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 18 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(23,22): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 19 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(27,15): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 20 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(28,17): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 21 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(29,19): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 22 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(29,26): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 23 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(35,19): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 24 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(36,20): error TS2331: 'this' cannot be referenced in a module or namespace body. |
| 25 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(41,14): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 26 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(41,21): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 27 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(46,23): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 28 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(46,30): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 29 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(50,18): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 30 | +tests/cases/conformance/types/thisType/thisTypeErrors.ts(50,25): error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 31 | + |
| 32 | + |
| 33 | +==== tests/cases/conformance/types/thisType/thisTypeErrors.ts (30 errors) ==== |
| 34 | + var x1: this; |
| 35 | + ~~~~ |
| 36 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 37 | + var x2: { a: this }; |
| 38 | + ~~~~ |
| 39 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 40 | + var x3: this[]; |
| 41 | + ~~~~ |
| 42 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 43 | + |
| 44 | + function f1(x: this): this { |
| 45 | + ~~~~ |
| 46 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 47 | + ~~~~ |
| 48 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 49 | + var y: this; |
| 50 | + ~~~~ |
| 51 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 52 | + return this; |
| 53 | + } |
| 54 | + |
| 55 | + interface I1 { |
| 56 | + a: { x: this }; |
| 57 | + ~~~~ |
| 58 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 59 | + b: { (): this }; |
| 60 | + ~~~~ |
| 61 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 62 | + c: { new (): this }; |
| 63 | + ~~~~ |
| 64 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 65 | + d: { [x: string]: this }; |
| 66 | + ~~~~ |
| 67 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 68 | + e: { f(x: this): this }; |
| 69 | + ~~~~ |
| 70 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 71 | + ~~~~ |
| 72 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 73 | + } |
| 74 | + |
| 75 | + class C1 { |
| 76 | + a: { x: this }; |
| 77 | + ~~~~ |
| 78 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 79 | + b: { (): this }; |
| 80 | + ~~~~ |
| 81 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 82 | + c: { new (): this }; |
| 83 | + ~~~~ |
| 84 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 85 | + d: { [x: string]: this }; |
| 86 | + ~~~~ |
| 87 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 88 | + e: { f(x: this): this }; |
| 89 | + ~~~~ |
| 90 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 91 | + ~~~~ |
| 92 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 93 | + } |
| 94 | + |
| 95 | + class C2 { |
| 96 | + static x: this; |
| 97 | + ~~~~ |
| 98 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 99 | + static y = <this>undefined; |
| 100 | + ~~~~ |
| 101 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 102 | + static foo(x: this): this { |
| 103 | + ~~~~ |
| 104 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 105 | + ~~~~ |
| 106 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 107 | + return undefined; |
| 108 | + } |
| 109 | + } |
| 110 | + |
| 111 | + namespace N1 { |
| 112 | + export var x: this; |
| 113 | + ~~~~ |
| 114 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 115 | + export var y = this; |
| 116 | + ~~~~ |
| 117 | +!!! error TS2331: 'this' cannot be referenced in a module or namespace body. |
| 118 | + } |
| 119 | + |
| 120 | + class C3 { |
| 121 | + x1 = { |
| 122 | + g(x: this): this { |
| 123 | + ~~~~ |
| 124 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 125 | + ~~~~ |
| 126 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 127 | + return undefined; |
| 128 | + } |
| 129 | + } |
| 130 | + f() { |
| 131 | + function g(x: this): this { |
| 132 | + ~~~~ |
| 133 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 134 | + ~~~~ |
| 135 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 136 | + return undefined; |
| 137 | + } |
| 138 | + let x2 = { |
| 139 | + h(x: this): this { |
| 140 | + ~~~~ |
| 141 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 142 | + ~~~~ |
| 143 | +!!! error TS2526: 'this' type is available only in a non-static member of a class or interface. |
| 144 | + return undefined; |
| 145 | + } |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | + |
0 commit comments