-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to do module augmentation for class constructor #19372
Comments
Hey there, this issue tracker isn't meant to work as a support forum. These questions tend to be better suited for StackOverflow. You may want to open a question up there instead in the future. But the short answer is that you need to do class-to-interface decomposiotion. |
I'm agree with you (I think it isn't possible to achieve this that's why I posted here). For now, the only way I found is to relay on prototype like this: I hope you understand my needs and you will continue to help me. |
there is no way currently to augment a class with a new constructor signature. the interface only augments the instance side of the class and not the constructor function. a |
For declaration files, class to interface decomposition would solve my problem only if every declaration files follow this rule, but as class is allowed in declaration file, then I think there should be a way to augment the class via an interface.
Now,
augmentation will show the 2 signatures as I was expecting. Thank you anyway for your help. |
I a afraid this is the wrong approach. An interface describes the shape of the instance not the constructor. The constructor signature are part of the constructor type and not the instance. |
TypeScript Version: 2.5.3
Code
Expected behavior:
m.C
constructor should display(s:string,n:number)
and(d:Date)
in intellisenseActual behavior:
m.C
constructor only displays(s:string,n:number)
You learn me how to augment a class from a module, but I'm unable to augment the class constructor.
Thank you in advance for your help.
The text was updated successfully, but these errors were encountered: