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
asd:numberit will error. I would post an issue here, github.com/microsoft/TypeScript/issues just double check a similar issue doesn't exist first. Handling implicit types in Typescript, is just as important as checking Types, otherwise we get Type Code bloat, (not good)..tgeneric like this. Does this fully address your question? If so I can write up an answer explaining and elaborating. If not, what am I missing?