Closed as not planned
Description
Issue:
Now that microsoft/TypeScript#41544 has landed, the sample problem is now solvable.
// Sample problem
function invokeLater(args: any[], callback: (...args: any[]) => void) {
/* ... Invoke callback with 'args' ... */
}
// Better solution
function invokeLater<T extends any[]>(...argsWithCallback: [...T, (...args: T) => void)]) {
const args = argsWithCallback.slice(0, -1) as T
const callback = argsWithCallback[argsWithCallback.length - 1] as (...args: T) => void
/* ... Invoke callback with 'args' ... */
}
Recommended Fix:
Document feature
Metadata
Metadata
Assignees
Labels
No labels