Skip to content

fix(es/helpers): Sync tslib _ts_generator implementation #10366

New issue

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

Merged
merged 5 commits into from
Apr 12, 2025
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
6 changes: 6 additions & 0 deletions .changeset/silly-seas-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_core: minor
swc_ecma_transforms_base: minor
---

fix(es/helpers): Sync tslib `_ts_generator` implementation
4 changes: 2 additions & 2 deletions crates/swc/tests/stacktrace/issue-622/output/stacks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ $DIR/tests/stacktrace/issue-622/input/index.js:3

ReferenceError: call is not defined
at <anonymous> ($DIR/tests/stacktrace/issue-622/input/index.js:3:9)
at step ($DIR/tests/stacktrace/issue-622/input/_exec.js:109:23)
at Object.next ($DIR/tests/stacktrace/issue-622/input/_exec.js:50:20)
at step ($DIR/tests/stacktrace/issue-622/input/_exec.js:105:23)
at Object.next ($DIR/tests/stacktrace/issue-622/input/_exec.js:46:20)
at asyncGeneratorStep ($DIR/tests/stacktrace/issue-622/input/_exec.js:4:28)
at _next ($DIR/tests/stacktrace/issue-622/input/_exec.js:22:17)
at $DIR/tests/stacktrace/issue-622/input/_exec.js:27:13
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function _ts_generator(thisArg, body) {
var f, y, t, g, _ = { label: 0, sent: function () { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] };
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
var f, y, t, _ = { label: 0, sent: function () { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,16 @@ function _async_to_generator(fn) {
};
}
function _ts_generator(thisArg, body) {
var f, y, t, g, _ = {
var f, y, t, _ = {
label: 0,
sent: function() {
if (t[0] & 1) throw t[1];
return t[1];
},
trys: [],
ops: []
};
return g = {
next: verb(0),
"throw": verb(1),
"return": verb(2)
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
return this;
}), g;
function verb(n) {
Expand All @@ -54,7 +50,7 @@ function _ts_generator(thisArg, body) {
}
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while(_)try {
while(g && (g = 0, op[0] && (_ = 0)), _)try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [
op[0] & 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,16 @@ function _async_to_generator(fn) {
};
}
function _ts_generator(thisArg, body) {
var f, y, t, g, _ = {
var f, y, t, _ = {
label: 0,
sent: function() {
if (t[0] & 1) throw t[1];
return t[1];
},
trys: [],
ops: []
};
return g = {
next: verb(0),
"throw": verb(1),
"return": verb(2)
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
return this;
}), g;
function verb(n) {
Expand All @@ -54,7 +50,7 @@ function _ts_generator(thisArg, body) {
}
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while(_)try {
while(g && (g = 0, op[0] && (_ = 0)), _)try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [
op[0] & 2,
Expand Down
12 changes: 4 additions & 8 deletions packages/core/__tests__/transform/preset-env_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,16 @@ it("should respect custom transform option", async () => {
};
}
function _ts_generator(thisArg, body) {
var f, y, t, g, _ = {
var f, y, t, _ = {
label: 0,
sent: function() {
if (t[0] & 1) throw t[1];
return t[1];
},
trys: [],
ops: []
};
return g = {
next: verb(0),
"throw": verb(1),
"return": verb(2)
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
return this;
}), g;
function verb(n) {
Expand All @@ -83,7 +79,7 @@ it("should respect custom transform option", async () => {
}
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while(_)try {
while(g && (g = 0, op[0] && (_ = 0)), _)try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [
op[0] & 2,
Expand Down
Loading