dc237b317e
* use emit into iife * Update emit * Revert un-related changes * Allow super in static context * Allow this and super in static property declaration * Add more tests * Avoid errors * Accept baseline * Accept baseline * Add decorated classes test * Add errors * Avoid this in emitter * make lint happy * Add class expression tests * Add computed name test * Avoid super if target below es6 * Adjust function boundary * Add internal * Fix minor CR issues * accept baseline * Update behavior * Avoid spaces * Make lint happy * Avoid function boundary utils * Update baseline * Avoid errors * Accept baseline * Accept baseline * Accept baseline * Accept baseline * Use substitutions * Full coverage for super, this, merge static and private context * Fix use-before-def in static fields Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
67 lines
3.1 KiB
Plaintext
67 lines
3.1 KiB
Plaintext
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(9,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
|
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(17,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
|
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(23,13): error TS2331: 'this' cannot be referenced in a module or namespace body.
|
|
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(31,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
|
|
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(33,25): error TS2507: Type 'undefined' is not a constructor function type.
|
|
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(39,9): error TS2332: 'this' cannot be referenced in current location.
|
|
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(40,9): error TS2332: 'this' cannot be referenced in current location.
|
|
|
|
|
|
==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (7 errors) ====
|
|
class BaseErrClass {
|
|
constructor(t: any) { }
|
|
}
|
|
|
|
class ClassWithNoInitializer extends BaseErrClass {
|
|
t;
|
|
//'this' in optional super call
|
|
constructor() {
|
|
super(this); // error: "super" has to be called before "this" accessing
|
|
~~~~
|
|
!!! 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 'undefined' 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.
|
|
}
|
|
|
|
export = this; // Should be an error |