I have write a class function that return the instance of myClass if it is not the instance of the class.
function myClass(){
if ( this instanceof myClass )
return myClass();
}
Hence, both new myClass() and myClass() and get the instance of the myClass.
myClass(); // return myClass instance
new myClass(); // return myClass instance
However, I don't know how to declare the above class in typescript declaration file.
If I write that:
class myClass{}
function myClass(): myClass;
This will be duplicate identifier error.
Is there any method to fix that? thanks!