使用帶有調(diào)用簽名的對(duì)象字面量來(lái)定義泛型函數(shù)interface IGenericIdentityFn1 {
}function identity<T>(arg: T): T { return arg;
}const myIdentityFn: {<T>(arg: T): T} = identity;const myIdentityFn2: IGenericIdentityFn1 = identity;這里兩種方式都報(bào)錯(cuò)ERROR:callable-types: Type literal has only a call signature — use <T>(arg: T) => T instead請(qǐng)問(wèn)需要怎么解決。
typescript 泛型調(diào)用簽名的對(duì)象字面量來(lái)定義泛型函數(shù)報(bào)錯(cuò)
慕妹3146593
2019-02-26 17:06:08