We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TypeScript Version: 2.6.2, 2.7.0-dev.20171203, target: es2015
Code
async function test(url) { console.log(url); } async function fn(url) { await test(url); var url; } fn("test");
Expected behavior: "test" should be logged
Actual behavior: undefined is logged
The generated code clobbers the var declaration in the outer function, by adding another function around the code:
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; function test(url) { return __awaiter(this, void 0, void 0, function* () { console.log(url); }); } function fn(url) { return __awaiter(this, void 0, void 0, function* () { yield test(url); var url; }); } fn("test");
The text was updated successfully, but these errors were encountered:
Looks like we need to hoist var declarations out of the generator function even in ES2015.
Sorry, something went wrong.
rbuckton
Successfully merging a pull request may close this issue.
TypeScript Version: 2.6.2, 2.7.0-dev.20171203, target: es2015
Code
Expected behavior:
"test" should be logged
Actual behavior:
undefined is logged
The generated code clobbers the var declaration in the outer function, by adding another function around the code:
The text was updated successfully, but these errors were encountered: