In Typescript, is there a difference between `return x` and `return await x`?

Viewed 115

In Typescript, is there a difference between return x and return await x?

Suppose we have:

async function func(): Promise<void> { }

async function option1(): Promise<void> {
    return await func();
}

async function option2(): Promise<void> {
    return func();
}

I know that when targeting ES5, option1() will require more code.

In ES2015 and ES2016 it will have an additional yield keyword.

In ES2017 - it will just appear as-is, with the additional await.

  1. Is there any logical difference between the two versions?
  2. Can they behave differently in some way when executed?
  3. Is there a performance difference in ES2015? And in ES2017?
0 Answers
Related