Today I had to write a function foo in TypeScript that would accept single argument of type object. Then I had another async function bar that would return object. These were the functions that would be heavily used by other engineers and play important role in our system — “core functions”

function foo(arg: object) {
  // ...
}
async function bar(): Promise<object> {
  // ...
}

A typical usage of these functions would be passing value returned from bar to foo

#conditional-types #generics #asyncawait #promises #typescript

How to Ensure that a Function Accepts a Value but not a Promise in TypeScript
2.00 GEEK