TypeScript/tests/baselines/reference/thisInInvalidContexts.errors.txt
Kanchalai Tanglertsampan f4290e1538 Update baselines
2016-01-26 15:37:19 -08:00

75 lines
3.3 KiB
Plaintext

tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(14,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(22,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS2507: Type 'any' is not a constructor function type.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(44,9): error TS2332: 'this' cannot be referenced in current location.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): error TS2332: 'this' cannot be referenced in current location.
==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts (8 errors) ====
//'this' in static member initializer
class ErrClass1 {
static t = this; // Error
~~~~
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
}
class BaseErrClass {
constructor(t: any) { }
}
class ClassWithNoInitializer extends BaseErrClass {
t;
//'this' in optional super call
constructor() {
super(this); // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
}
}
class ClassWithInitializer extends BaseErrClass {
t = 4;
//'this' in required super call
constructor() {
super(this); // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
}
}
module M {
//'this' in module variable
var x = this; // Error
~~~~
!!! error TS2331: 'this' cannot be referenced in a module or namespace body.
}
//'this' as type parameter constraint
// function fn<T extends this >() { } // Error
//'this' as a type argument
function genericFunc<T>(x: T) { }
genericFunc<this>(undefined); // Should be an error
~~~~
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
class ErrClass3 extends this {
~~~~
!!! error TS2507: Type 'any' is not a constructor function type.
}
//'this' as a computed enum value
enum SomeEnum {
A = this, // Should not be allowed
~~~~
!!! error TS2332: 'this' cannot be referenced in current location.
B = this.spaaaace // Also should not be allowed
~~~~
!!! error TS2332: 'this' cannot be referenced in current location.
}