TypeScript/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt

67 lines
1.9 KiB
Plaintext

==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (9 errors) ====
//'this' in static member initializer
class ErrClass1 {
static t = this; // Error
~~~~
!!! '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); // OK
}
}
class ClassWithInitializer extends BaseErrClass {
t = 4;
//'this' in required super call
constructor() {
super(this); // Error
~~~~
!!! 'this' cannot be referenced in current location.
}
}
module M {
//'this' in module variable
var x = this; // Error
~~~~
!!! 'this' cannot be referenced in a module 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
class ErrClass3 extends this {
~~~~
!!! Identifier expected.
~
!!! ';' expected.
}
//'this' as a computed enum value
enum SomeEnum {
A = this, // Should not be allowed
~~~~
!!! 'this' cannot be referenced in current location.
B = this.spaaaace // Also should not be allowed
~~~~
!!! 'this' cannot be referenced in current location.
}
export = this; // Should be an error
~~~~~~~~
!!! Cannot compile external modules unless the '--module' flag is provided.
~~~~
!!! Identifier expected.