Given a plain JS function that takes in an array of callbacks (that each returns an object), and then returns their combined output:
export const applyCallback = (callbacks) => {
return callbacks.reduce((acc, callback) => { ...acc, ...callback() }, {});
}
How would one appropriately type this using TypeScript to infer the return type of applyCallback? Although I am aware of ReturnType, it applies to a single function, meanwhile here I would want to get a ReturnType of each callback and create a union of their return types.