Reputation: 313
With the following code, how would I replace the any
s if it is even possible. I would like to remove the warning from TS "Unexpected any. Specify a different type"
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.
Upvotes: 1
Views: 35
Reputation: 863
Use a generic type
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
});
Upvotes: 2