Is it possible to define an annotation for a function that accepts a callback, and have the function return type determined by the callback's return type?
// Suppose the callback takes a number as argument
function processCallback(cb: (arg:number) => infer T /* error */ ) {
return cb(42)
}
processCallback(x => 'bar') // expected to infer 'string'