2014-09-12 22:35:07 +02:00
|
|
|
tests/cases/compiler/thisInOuterClassBody.ts(5,16): error TS2334: 'this' cannot be referenced in a static property initializer.
|
|
|
|
tests/cases/compiler/thisInOuterClassBody.ts(12,22): error TS2339: Property 'y' does not exist on type 'Foo'.
|
|
|
|
tests/cases/compiler/thisInOuterClassBody.ts(18,22): error TS2339: Property 'x' does not exist on type 'typeof Foo'.
|
|
|
|
|
|
|
|
|
2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/thisInOuterClassBody.ts (3 errors) ====
|
|
|
|
class Foo {
|
|
|
|
|
|
|
|
x = this;
|
|
|
|
|
|
|
|
static y = this;
|
|
|
|
~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
bar() {
|
|
|
|
|
|
|
|
this.x; // 'this' is type 'Foo'
|
|
|
|
|
|
|
|
var f = () => this.x; // 'this' should be type 'Foo' as well
|
|
|
|
var p = this.y;
|
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2339: Property 'y' does not exist on type 'Foo'.
|
2014-07-13 01:04:16 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bar2() {
|
|
|
|
var a = this.y;
|
|
|
|
var b = this.x;
|
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2339: Property 'x' does not exist on type 'typeof Foo'.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
}
|