Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This usage before super call #4211

Closed
wgebczyk opened this issue Aug 7, 2015 · 0 comments
Closed

This usage before super call #4211

wgebczyk opened this issue Aug 7, 2015 · 0 comments
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript ES6 Relates to the ES6 Spec Fixed A PR has been merged for this issue

Comments

@wgebczyk
Copy link

wgebczyk commented Aug 7, 2015

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.

@mhegazy mhegazy added Bug A bug in TypeScript ES6 Relates to the ES6 Spec labels Aug 7, 2015
@mhegazy mhegazy added this to the TypeScript 1.7 milestone Aug 12, 2015
@mhegazy mhegazy modified the milestones: TypeScript 1.7, TypeScript 1.8 Oct 9, 2015
@mhegazy mhegazy added the Breaking Change Would introduce errors in existing code label Dec 8, 2015
@yuit yuit added the Fixed A PR has been merged for this issue label Jan 28, 2016
@mhegazy mhegazy closed this as completed Feb 16, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript ES6 Relates to the ES6 Spec Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants