TypeScript function overload All In One
TypeScript 函数重载
errors
// This overload signature is not compatible with its implementation signature.(2394)
function myFunction(fn: (a: string) => void, value: string): void;
function myFunction(fn: (a: number) => void, value: number): void;
// function overload 重载
// 参数类型。参数数量 不同
function myFunction(fn: (a: string | number) => void, value: string | number): void {
// Implementation
}
// function myFunction(fn: (a: string | number) => void, value: string | number, xyz: number): void {
// // Implementation
// }
solutions