DEV Community

Discussion on: 9 tricks that separate a pro Typescript developer from an noob 😎

Collapse
 
ruppysuppy profile image
Tapajyoti Bose

The only difference is when using async, the return type gets wrapped by a Promise

const asyncFn = async () => 0; // type AsyncFn = () => Promise<number>
Enter fullscreen mode Exit fullscreen mode

When you await, the Promise gets unwrapped & you can use it as a regular value

const func = async () => {
  const result = await asyncFn(); // type Result = number
}
Enter fullscreen mode Exit fullscreen mode

Everything else mentioned in the article still holds true regardless whether you are using Promises or not