Skip to content

Playground doesn't support async generators. #15

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
cakoose opened this issue Mar 30, 2018 · 4 comments
Closed

Playground doesn't support async generators. #15

cakoose opened this issue Mar 30, 2018 · 4 comments
Assignees
Labels
Playground ATA Holes in the current type acquisition Playground Issues that affect the Playground

Comments

@cakoose
Copy link

cakoose commented Mar 30, 2018

I put the following code into https://www.typescriptlang.org/play/

async function f(): Promise<number> {
    return 1;
}

async function* g(): AsyncIterator<number> {
    yield 1;
    await f();
    return 2;
}

The compiler reports two errors on the async function *g() line.

  • Cannot find global type 'AsyncIterableIterator'
  • Cannot find name 'AsyncIterator'

Is that expected?

@mhegazy
Copy link

mhegazy commented Apr 2, 2018

The playground does not have a way to set compiler options, e.g. target, or --lib. it is similar to microsoft/TypeScript#18209.
The long term solution is to make it configurable. as a short term fix i will add the latest lib file.

@justjake
Copy link

Bump: it can't find AsyncIterableIterator:

async function* generate() {
    yield 0
    yield 1
    yield 2
}

type Returned = ReturnType<typeof generate>

reports Error: Cannot find global type AsyncIterableIterator'.

https://www.typescriptlang.org/play/#src=async%20function*%20generate()%20%7B%0D%0A%20%20%20%20yield%200%0D%0A%20%20%20%20yield%201%0D%0A%20%20%20%20yield%202%0D%0A%7D%0D%0A%0D%0Atype%20Returned%20%3D%20ReturnType%3Ctypeof%20generate%3E

@orta orta transferred this issue from microsoft/TypeScript Jul 10, 2019
@saarw
Copy link

saarw commented Oct 22, 2019

Also getting 'Cannot find name "AsyncGenerator"'

@orta
Copy link
Contributor

orta commented Mar 10, 2021

Setting the target to ESNext works with all these samples out of the box o the playground 👍🏻

@orta orta closed this as completed Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Playground ATA Holes in the current type acquisition Playground Issues that affect the Playground
Projects
None yet
Development

No branches or pull requests

6 participants