TypeScript/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt
Cyrus Najmabadi a1e18fc22b Introduce a new HeritageClauseElment type.
This type represents the expression+type arguments you can get in a class or interface
heritage clause section.  For class-implements clauses, or interface-extends clauses,
these expressions can only be identifiers or dotted names.  For class extends clauses,
these could be any expressions in the future.  However, for now, we only support identifiers
and dotted names.
2015-03-31 12:29:02 -07:00

72 lines
No EOL
3.1 KiB
Text

tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(22,15): error TS2332: 'this' cannot be referenced in current location.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(28,13): error TS2331: 'this' cannot be referenced in a module body.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS9002: Only type references are currently supported in a class 'extends' clauses.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(44,9): error TS2332: 'this' cannot be referenced in current location.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(45,9): error TS2332: 'this' cannot be referenced in current location.
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(48,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (7 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); // OK
}
}
class ClassWithInitializer extends BaseErrClass {
t = 4;
//'this' in required super call
constructor() {
super(this); // Error
~~~~
!!! error TS2332: 'this' cannot be referenced in current location.
}
}
module M {
//'this' in module variable
var x = this; // Error
~~~~
!!! error TS2331: '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 {
~~~~
!!! error TS9002: Only type references are currently supported in a class 'extends' clauses.
}
//'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.
}
export = this; // Should be an error
~~~~~~~~~~~~~~
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.