Overloading typescript constructor like cpp or Java with a catch

<p>When ever I was looking into the typescript Date class constructor implementation, I always wondered how its constructor signature worked like that, how it can have many signature, how can it work with 1st argument as number or string or an instance of itself. Every time I tried to implement the constructor signature in typescript using the documentation like typescript says I was getting type error shown below.</p> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:630/1*gSrFHn2_nTLUEDVZdI5QQw.png" style="height:375px; width:700px" /></p> <p>The type error for empty construction overloading</p> <blockquote> <p>I was working on&nbsp;<a href="https://github.com/opensource-nepal/node-nepali-datetime" rel="noopener ugc nofollow" target="_blank"><strong>node-nepali-datetime</strong></a>&nbsp;open source package in github.You might be thinking now that this is reinventing the wheel. The reason is that Nepal is around 60 years into the future. The first month of Nepalse calender, the&nbsp;<strong>Bikram Sambat calender</strong>, is Baisakh. It falls somewhere around April and has other similar features like the English (A.D) calender.</p> </blockquote> <p>But whenever I looked into typescript implementation for date. I could see something that there were 5 different overload for date.</p> <p><a href="https://medium.com/@nirjalpaudel54312/overloading-typescript-constructor-like-c-java-or-c-with-a-catch-b23267daec62">Visit Now</a></p>