Skip to content

Error using 'for await' on a union. #16153

Closed
@rbuckton

Description

@rbuckton

TypeScript Version: nightly (2.4.0-dev.20170530)

Code

async function f<T>(source: Iterable<T> | AsyncIterable<T>) {
  for await (const x of source) { 
  }
}

Expected behavior:

x has type T

Actual behavior:

error TS2504: Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions