You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior:
I would expect that when the above code compiles, that the private members get initialized with values after the super call like below:
Actual behavior:
the private members which have values gets assigned to before the super call. This behaviour only happens when I call a function before a super call, even if said function does not alter this in the code (like below).
Given this issue has yet to be resolved, I wanted to share a current work around with anyone who may be experiencing this as well:
When creating private memebers, if you don't provide them with default values in the head of your class, but instead initialize them in the constructor explicitely, it will compile correctly.
i.e.
function example ( number: number ) {
return number;
}
class ExtString extends String {
private x: number;
private y: number;
z: number;
constructor(...args){
example(args[0]);
super(...args);
this.z = 19;
this.y = 10;
this.x = 20;
}
}
TypeScript Version: 3.3.0-dev.201xxxxx
Search Terms:
Code
Expected behavior:
I would expect that when the above code compiles, that the private members get initialized with values after the super call like below:
Actual behavior:
the private members which have values gets assigned to before the super call. This behaviour only happens when I call a function before a super call, even if said function does not alter
this
in the code (like below).This results in a compile time error.
Related Issues:
I found a similar bug that is referenced here #8277
The text was updated successfully, but these errors were encountered: