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
|
tests/cases/conformance/types/thisType/declarationFiles.ts(4,20): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
tests/cases/conformance/types/thisType/declarationFiles.ts(30,5): error TS2527: The inferred type of 'x1' references an inaccessible 'this' type. A type annotation is necessary.
tests/cases/conformance/types/thisType/declarationFiles.ts(32,5): error TS2527: The inferred type of 'x3' references an inaccessible 'this' type. A type annotation is necessary.
tests/cases/conformance/types/thisType/declarationFiles.ts(34,5): error TS2527: The inferred type of 'f1' references an inaccessible 'this' type. A type annotation is necessary.
tests/cases/conformance/types/thisType/declarationFiles.ts(40,5): error TS2527: The inferred type of 'f3' references an inaccessible 'this' type. A type annotation is necessary.
==== tests/cases/conformance/types/thisType/declarationFiles.ts (5 errors) ====
class C1 {
x: this;
f(x: this): this { return undefined; }
constructor(x: this) { }
~~~~
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
}
class C2 {
[x: string]: this;
}
interface Foo<T> {
x: T;
y: this;
}
class C3 {
a: this[];
b: [this, this];
c: this | Date;
d: this & Date;
e: (((this)));
f: (x: this) => this;
g: new (x: this) => this;
h: Foo<this>;
i: Foo<this | (() => this)>;
j: (x: any) => x is this;
}
class C4 {
x1 = { a: this };
~~
!!! error TS2527: The inferred type of 'x1' references an inaccessible 'this' type. A type annotation is necessary.
x2 = [this];
x3 = [{ a: this }];
~~
!!! error TS2527: The inferred type of 'x3' references an inaccessible 'this' type. A type annotation is necessary.
x4 = () => this;
f1() {
~~
!!! error TS2527: The inferred type of 'f1' references an inaccessible 'this' type. A type annotation is necessary.
return { a: this };
}
f2() {
return [this];
}
f3() {
~~
!!! error TS2527: The inferred type of 'f3' references an inaccessible 'this' type. A type annotation is necessary.
return [{ a: this }];
}
f4() {
return () => this;
}
}
|