interface Foo1 {
(param: number): number
(param: string): string
}
const foo1: Foo1 = (param: number | string) => param as any
const foo2 = <T>(param: T) : T => param
interface Foo3<T1, T2> {
(param: T1): T1
(param: T2): T2
}
const foo3: Foo3<T1, T2> = <T1, T2>(param: T1 | T2) => param as any
// [ts] Cannot find name 'T1'. [2304]
// [ts] Cannot find name 'T2'. [2304]
我在StackOverflow上进行了搜索,但是问题只谈论其中一个,或者没有回答问题。