Closed
Description
Currently when class-declaration has property declaration with initialize and parameter property declaration, super
call must be the first statement. So the following case is not valid
class B {}
class C extends B{
blah = 2;
constructor() {
if (true) { super (); }
}
}
class B {}
class C extends B{
blah = 2;
constructor() {
let x = super();
}
}
We should allow above cases as, @RyanCavanaugh points out in this comment for possible solutions.
Quoted from the comment:
- If super(...) is in an expression statement whose parent is a control flow statement (i.g. if (true) super()), rewrite it as a block containing a super call and its initializers
- If super(...) is in any other expression position, emit (super(...), this.prop1 = value1, this.prop2 = value2, ..., this)