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
```typescript
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);
}

console.log(createDate(554356800));
console.log(createDate(12,27,1987));
```

Last updated