TypeScript: use of generic and union types
问题 I have code which uses function overload, something like: function f0(v: Object): void { } function f1(a: number, b: number): void; function f1(a: string, b: string): void; function f1(a: any, b: any): void { f0(a); // OK } That I would like to convert using union types, but I get an error: function f1<T extends number | string>(a: T, b: T): void { f0(a); // Error: Argument of type 'T' is not assignable to parameter of type 'Object'. } What's wrong here, knowing that the following is OK: