-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" insteadDuplicateAn existing issue was already createdAn existing issue was already created
Description
Please see following:
class A {
name: String = 'test A';
constructor() {
console.log(this.name);
}
}
class B extends A {
name: String = 'test B'
}
new B(); // 'test A'
It will return 'test A', but 'test B' is more obvious output for this code. And also it is very handy to have an ability to override property default value in subclasses.
It cam be easily achieved, if implicit super() call on B will be made after property assignment, just compile to this:
...
function B() {
this.name = 'test B';
_super.apply(this, arguments);
}
...
instead of this:
...
function B() {
_super.apply(this, arguments);
this.name = 'test B';
}
...
You can see example here: http://bit.ly/1cjaMeJ
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" insteadDuplicateAn existing issue was already createdAn existing issue was already created