Conversation
Contributor
Author
|
I will also need to patch tslib. |
sandersn
approved these changes
Apr 18, 2017
|
I can still reproduce this issue with TypeScript // Run with "tsc && node --harmony test.js"
// Node.js version: 9.7.1
declare const console: any;
async function *asyncGenerator(): AsyncIterable<number> {
yield 1;
yield Promise.resolve(2);
}
(async function() {
const iterator: AsyncIterator<number> = asyncGenerator()[Symbol.asyncIterator]();
// Should be {value: 1, done: false}
console.log(await iterator.next());
// Should be {value: 2, done: false}
//
// But actually is { value: Promise { 2 }, done: false } with the
// following targets: es5, es6, es20{15, 16, 17, 18}.
// The target "esnext" prevents any downcompilation and therefore
// works natively on Node.js/V8 as intended.
console.log(await iterator.next());
// Should be {value: undefined, done: true}
console.log(await iterator.next());
})();tsconfig.json: {
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": [
"es6",
"esnext.asynciterable",
],
"importHelpers": true,
"downlevelIteration": true,
"strict": true,
}
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes an issue where we do not implicitly await the operand to
yieldor the iterated elements of the operand toyield*as per https://tc39.github.io/proposal-async-iteration/#sec-asyncgenerator-definitions-evaluation.Fixes #15205