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
The first statement in the body of a constructor must be a super call if both of the following are true:
• The containing class is a derived class.
• The constructor declares parameter properties or the containing class declares instance member variables with initializers.
These don't seem to be the only two conditions.
Consider this:
classMyViewextendsBackbone.View{privatesomeProp:SomeType;constructor(options:MyOptionsType){// I want to create my view with these configured events:options.events={'click .btn-close': this.close};super(options);this.someProp=newSomeType();}}
This results in a compiler error: error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
The MyView class does not contain initialized properties or parameter properties. What's going on here?
The text was updated successfully, but these errors were encountered:
wait, nm. This was caused by my own mistake. sorry...
For anyone else having this issue, here's how I got confused
classMyViewextendsBackbone.View{privatesomeProp:SomeType;constructor(options:MyOptionsType){// I want to create my view with these configured events:options.events={'click .btn-close': this.close};super(options);this.someProp=newSomeType();}// Converted incorrectly from JS // MyView.prototype.mySuperCoolMethod = function() { }// Should be:// private mySuperCoolMethod() {}// Otherwise TypeScript considers this an "initialized property".privatemySuperCoolMethod=function(){}}
From #945
These don't seem to be the only two conditions.
Consider this:
This results in a compiler error:
error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
The
MyView
class does not contain initialized properties or parameter properties. What's going on here?The text was updated successfully, but these errors were encountered: