Why Typescript doesn't support function overloading in a right way?
问题 There are a lot of questions about how function overloading works in Typescript, (for instance, TypeScript function overloading). But there are no questions like 'why does it work in that way?' Now function overloading looks like that: function foo(param1: number): void; function foo(param1: number, param2: string): void; function foo(...args: any[]): void { if (args.length === 1 && typeof args[0] === 'number') { // implementation 1 } else if (args.length === 2 && typeof args[0] === 'number'