Suppose I have a function partial(), that takes a callable and arguments that have to be passed to it, and prefills the first argument of the callable.
How should I annotate its parameters for the type check to work, no matter which callable I pass to it.
function foo(a: string, b: number, c: string) {
console.log('foo', a, b, c)
}
function bar(a: string) {
console.log('bar', a)
}
function partial(callable, ...args) {
callable('identity', ...args)
}
If it helps, this is what I am currently trying, but doesn't quite work:
partial<T>(callable: (...args: [string, ...T[]]) => void, ...args: T[]) {
callable('partial a', ...args);
}