Docs / Code to an accompanying video course on async/await with TypeScript.
npm install
- Simplify callbacks with async await
- 02 Promise
- 03 Async Await
- 04 Serial / Parallel / Race execution, Control flow
- 05 Asynchronous iteration using for-await-of
What does this function return?
async function foo() { return 123; }
TypeScript knows :)
What does this function return:
declare function backend(): Promise<{key: string}>; async function foo() { return backend() .catch(err => { console.log('Backend failure:', err); }); }
I see this code out in the wild all the time.
Hopefully you can see that even for really simple codebases, when dealing with async await and promises, it is great to have TypeScript on your side.
Worth mentioning.