-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.3.0-dev.20170303
Code
// A *self-contained* demonstration of the problem follows...
class FooAsyncIterator implements AsyncIterator<string> {
next(value?: any) {
return Promise.resolve({
value: 'foooo',
done: true
});
}
}
class FooAsyncIterable implements AsyncIterable<string> {
[Symbol.asyncIterator]() {
return new FooAsyncIterator()
}
}
const fooBucket2: AsyncIterable<string> = {
[Symbol.asyncIterator]() {
return new FooAsyncIterator()
}
};
const fooAsyncIterable = new FooAsyncIterable();
async function foo() {
// no error here
for await (const s3obj of fooBucket2) {
}
// fooAsyncIterable has error:
/*
[ts] The type returned by the 'next()' method of an iterator must have a 'value' property.
*/
for await (const s3obj of fooAsyncIterable) {
}
}Expected behavior:
The build should pass
Actual behavior:
typecheck error:
[ts] The type returned by the 'next()' method of an iterator must have a 'value' property.
const fooAsyncIterable: FooAsyncIterable
you can see the code here:
https://github.com/Bnaya/async-iterator-type-issue/blob/master/src/index.ts
travis build log:
https://travis-ci.org/Bnaya/async-iterator-type-issue/jobs/207521422#L205
Ann-Dederkal
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue