使用以下代码,any如果可能的话,我将如何替换 s 。我想删除 TS 中的警告“任何意外。指定不同的类型”interface Props { isPrime: boolean;}interface Other { isEdit: boolean;}type TFunc = (a: any, b: any) => any;const myFunc = (c: TFunc) => (a: any) => (b: any) => c(a, b);const funcA = myFunc((props: Props, other: Other) => { // ..somecode}// Code to call the func A result ect.
1 回答
慕田峪9158850
TA贡献1794条经验 获得超7个赞
使用泛型类型
interface Props {
isPrime: boolean;
}
interface Other {
isEdit: boolean;
}
type TFunc<T, U> = (a: T, b: U) => any;
const myFunc = <T, U>(c: TFunc<T, U>) => (a: T) => (b: U) => c(a, b);
const funcA = myFunc<Props, Other>((props: Props, other: Other) => {
// ..somecode
});
添加回答
举报
0/150
提交
取消