Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/transformers/es2018.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ namespace ts {
context.requestEmitHelper(asyncGeneratorHelper);

// Mark this node as originally an async function
(generatorFunc.emitNode || (generatorFunc.emitNode = {} as EmitNode)).flags |= EmitFlags.AsyncFunctionBody;
(generatorFunc.emitNode || (generatorFunc.emitNode = {} as EmitNode)).flags |= EmitFlags.AsyncFunctionBody | EmitFlags.ReuseTempVariableScope;

return createCall(
getUnscopedHelperName("__asyncGenerator"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//// [nullishCoalescingOperatorInAsyncGenerator.ts]
// https://github.com/microsoft/TypeScript/issues/37686
async function* f(a: { b?: number }) {
let c = a.b ?? 10;
while (c) {
yield c--;
}
}


//// [nullishCoalescingOperatorInAsyncGenerator.js]
// https://github.com/microsoft/TypeScript/issues/37686
function f(a) {
var _a;
return __asyncGenerator(this, arguments, function* f_1() {
let c = (_a = a.b) !== null && _a !== void 0 ? _a : 10;
while (c) {
yield yield __await(c--);
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//// [nullishCoalescingOperatorInAsyncGenerator.ts]
// https://github.com/microsoft/TypeScript/issues/37686
async function* f(a: { b?: number }) {
let c = a.b ?? 10;
while (c) {
yield c--;
}
}


//// [nullishCoalescingOperatorInAsyncGenerator.js]
// https://github.com/microsoft/TypeScript/issues/37686
function f(a) {
var _a;
return __asyncGenerator(this, arguments, function f_1() {
var c;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
c = (_a = a.b) !== null && _a !== void 0 ? _a : 10;
_b.label = 1;
case 1:
if (!c) return [3 /*break*/, 4];
return [4 /*yield*/, __await(c--)];
case 2: return [4 /*yield*/, _b.sent()];
case 3:
_b.sent();
return [3 /*break*/, 1];
case 4: return [2 /*return*/];
}
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//// [nullishCoalescingOperatorInAsyncGenerator.ts]
// https://github.com/microsoft/TypeScript/issues/37686
async function* f(a: { b?: number }) {
let c = a.b ?? 10;
while (c) {
yield c--;
}
}


//// [nullishCoalescingOperatorInAsyncGenerator.js]
// https://github.com/microsoft/TypeScript/issues/37686
async function* f(a) {
let c = a.b ?? 10;
while (c) {
yield c--;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @target: esnext,es2015,es5
// @lib: esnext
// @noEmitHelpers: true
// @noTypesAndSymbols: true

// https://github.com/microsoft/TypeScript/issues/37686
async function* f(a: { b?: number }) {
let c = a.b ?? 10;
while (c) {
yield c--;
}
}