-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".FixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
Consider this code:
class Super {
_view:Element;
constructor(view?:Element) {
this._view = view || document.createElement('div');
};
}
class Inherits extends Super {
test = 1;
view:Element;
constructor() {
let view = document.createElement('span');
super(view);
this.view = view;
};
}
And it says: 2376 A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
I understand that it's because of test
property. but can you allow not-this
code before super()
call how ES6 does?
Also, this won't work too, of course:
class Inherits extends Super {
test = 1;
view:Element = document.createElement('span');
constructor() {
super(this.view); // 2332 'this' cannot be referenced in current location.
};
}
Metadata
Metadata
Assignees
Labels
Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".FixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript