Skip to content

Native await keyword is not used in async generator even after es2017 #23695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
falsandtru opened this issue Apr 25, 2018 · 8 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@falsandtru
Copy link
Contributor

falsandtru commented Apr 25, 2018

TypeScript Version: master

Search Terms:

Code

async function f() {
  await 0;
}
async function* g() {
  await 0;
  yield await 0;
}
$ node built/local/tsc.js index.ts -t es2017 --lib esnext

Expected behavior:

async function f() {
    await 0;
}
function g() {
    return __asyncGenerator(this, arguments, function* g_1() {
        await 0;
        yield await 0;
    });
}

Actual behavior:

async function f() {
    await 0;
}
function g() {
    return __asyncGenerator(this, arguments, function* g_1() {
        yield __await(0);
        yield yield __await(0);
    });
}

Playground Link:

Related Issues:

@mhegazy mhegazy added Bug A bug in TypeScript Help Wanted You can do this labels Apr 25, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Apr 25, 2018

Should be covered by #20463.

A PR for #20463 is welcomed.

@mhegazy mhegazy added Duplicate An existing issue was already created and removed Bug A bug in TypeScript Help Wanted You can do this labels Apr 25, 2018
@falsandtru
Copy link
Contributor Author

@mhegazy This issue targets es2017 but #20463 targets es2018. That issue really covers this?

@mhegazy mhegazy added Bug A bug in TypeScript ES2017 Relates to the ES2017 Spec Help Wanted You can do this and removed Duplicate An existing issue was already created labels Apr 26, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Apr 26, 2018

you are correct. it is part of es2017. PRs welcomed.

@weswigham
Copy link
Member

It's not part of es2017. Async functions are part of es2017, but asynchronous generators (and async for loops) are still just a stage-3 proposal.

@falsandtru
Copy link
Contributor Author

I think you can fix this issue without touching part of async generator.

@Jessidhia
Copy link

Jessidhia commented Apr 27, 2018

The generated code looks correct. Your example of "correct" code would be a syntax error even in ES2018 engines because you are using the await keyword outside of an async function.

@falsandtru
Copy link
Contributor Author

Right, I can't think of a solution to that issue for now.

@mhegazy mhegazy added Duplicate An existing issue was already created and removed Bug A bug in TypeScript ES2017 Relates to the ES2017 Spec Help Wanted You can do this labels Apr 27, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Apr 27, 2018

We can do it as part of es2018.

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants