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
{{ message }}
Repository navigation
Provide declare keyword support for class methods #38008
Although it seems that the example can be replaced by a generic, what if there are multiple return types that had to replace?
I know I can use an interface with the name of the class to override the method, but this only works for public members, not protected or private ones.
More importantly, if declare keyword already supports class properties, why don't add support to class methods as well?
Activity
RyanCavanaugh commentedon Apr 16, 2020
What you're asking for is #5863
JasonHK commentedon Apr 17, 2020
Ryan Cavanaugh (@RyanCavanaugh) No, this is a different idea. Let me give you another example:
TypeScript Playground
Although it seems that the example can be replaced by a generic, what if there are multiple return types that had to replace?
I know I can use an interface with the name of the class to override the method, but this only works for public members, not protected or private ones.
More importantly, if
declarekeyword already supports class properties, why don't add support to class methods as well?JasonHK commentedon May 25, 2020
Ryan Cavanaugh (@RyanCavanaugh) Should I write a proposal for this?
whzx5byb commentedon Oct 10, 2020
declare protected toObject: () => ObjectMixin<ExtendedInterface>;should work?JasonHK commentedon Feb 20, 2021
whzx5byb Yes, this will work. But I hope
declaremethods would be supported as well.Sorry for the late reply 😅
JasonHK commentedon Feb 21, 2021
whzx5byb Well... There's a problem with this approach though, you cannot use a method to override a property, which means this will not work: