TypeScript Best Practices

Creating a function in typescript with the expected parameter types, can make the tcs compiler happy, but this is practically missing the point of using TypeScript.

Todo this right, a function implementation must be implemented with the expected parameters, and the return type.

// Some code
function createDate(timestamp:number):Date;
function createDate(month:number,day: number, year: number): Date;
function createDate(monthOrTimestamp: number, day?:number,year?: number){
    return day === undefined || year === undefined
    ? new Date(monthOrTimestamp)
    : new Date(year, monthOrTimestamp, day);


Last updated