I have the following function and its callback type:
type Callbacks = {
onSuccess: (a: string) => void;
};
function t(event: string, ...args: [...any, Callbacks]) {
}
It works as expected but one thing, onSuccess function has a string param but TS can't recognize it and says that it has any type but I explicitly set it to string.
t("eventName", "bobo", 123, {onSuccess: (asd) => {
// "asd" is a string but TS says that it's an any
// Parameter 'asd' implicitly has an 'any' type
}})
What should I change in order to let TS recognize the callback's params type because manually specifying them every time is tedious?
P.S. it's a simplified example of my problem