Skip to content

This usage before super call #4211

Closed
Closed
@wgebczyk

Description

@wgebczyk

ES6 disallow to use this before super call.

class Aaa {
  constructor(v: () => number) {
  }
}
class Bbb extends Aaa {
  vv: number;
  constructor() {
    this.vv = 111;
    super(this.vvv);
  }
  vvv(): number { return 0; }
}

The line "this.vv = 111;" must be after super statement.
The super statement also cannot contain this usage.
Compilation to ES6 gives:

class Aaa {
    constructor(v) {
    }
}
class Bbb extends Aaa {
    constructor() {
        this.vv = 111;
        super(this.vvv);
    }
    vvv() { return 0; }
}

So even if TS wants to relax "this usage before super" (which i doubt), then it must fix in generated ES6 code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeBugA bug in TypeScriptES6Relates to the ES6 SpecFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions