TypeScript/tests/cases/compiler/collisionSuperAndParameter.ts
Wesley Wigham 9b558f9535
Remove _this, _super, and _newTarget name conflict errors (#22890)
* Add new generated name kind for reused transpiler variables

* Remove error on _super or _newTarget conflict

* Add test with super helper conflict

* Remove error on _this conflict

* Fix lint

* Use flags instead of generated kinds, inline some things

* Accept rename

* Remove trailing whitespace

* Move helper emit into printer, rather than emitter"

* passthru module and target

* New test, accept baselines

* Make members private
2018-03-30 17:43:37 -07:00

63 lines
1.8 KiB
TypeScript

// @target: es5
class Foo {
a() {
var lamda = (_super: number) => { // No Error
return x => this; // New scope. So should inject new _this capture
}
}
b(_super: number) { // No Error
var lambda = () => {
return x => this; // New scope. So should inject new _this capture
}
}
set c(_super: number) { // No error
}
}
class Foo2 extends Foo {
x() {
var lamda = (_super: number) => { // Error
return x => this; // New scope. So should inject new _this capture
}
}
y(_super: number) { // Error
var lambda = () => {
return x => this; // New scope. So should inject new _this capture
}
}
set z(_super: number) { // Error
}
public prop3: {
doStuff: (_super: number) => void; // no error - no code gen
}
public prop4 = {
doStuff: (_super: number) => { // should be error
}
}
constructor(_super: number) { // should be error
super();
}
}
declare class Foo3 extends Foo {
x();
y(_super: number); // No error - no code gen
constructor(_super: number); // No error - no code gen
public prop2: {
doStuff: (_super: number) => void; // no error - no code gen
};
public _super: number; // No error
}
class Foo4 extends Foo {
constructor(_super: number); // no code gen - no error
constructor(_super: string);// no code gen - no error
constructor(_super: any) { // should be error
super();
}
y(_super: number); // no code gen - no error
y(_super: string); // no code gen - no error
y(_super: any) { // Error
var lambda = () => {
return x => this; // New scope. So should inject new _this capture
}
}
}