3 ms·
Have you tried this: function doSth<A, B>(a: A, b: B): B { /* ... */ } function callFn<Args extends any[], Out>(fn: (...args: Args) => Out, ...args: A
by SebastianKra 4y ago
Have you tried this:
function doSth<A, B>(a: A, b: B): B { /* ... */ }
function callFn<Args extends any[], Out>(fn: (...args: Args) => Out, ...args: Args): Out { /* ... */ }
const foo = callFn(doSth, 'asdf', 'bsd' as const) // a: 'bsd'
const bar = callFn(doSth, 'asdf') // error
- svrtknst 4y agoI've tried something similar, but splitting the args into Head and Tail and extending the Parameters<F> of the input function and some other trickery Been a little while since I looked at it tho