mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 10:12:42 +03:00
fix(es/compat): Handle async
in class method parameters (#5560)
This commit is contained in:
parent
ef4fdd84e4
commit
f2c1164026
12
crates/swc/tests/fixture/issues-5xxx/5558/1/input/.swcrc
Normal file
12
crates/swc/tests/fixture/issues-5xxx/5558/1/input/.swcrc
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "ecmascript"
|
||||
},
|
||||
"target": "es2016"
|
||||
},
|
||||
"module": {
|
||||
"type": "es6"
|
||||
},
|
||||
"isModule": true
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
bar(x = async () => await 1) {
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
|
||||
class Foo {
|
||||
bar(x = /*#__PURE__*/ _async_to_generator(function*() {
|
||||
return yield 1;
|
||||
})) {}
|
||||
}
|
22
crates/swc/tests/fixture/issues-5xxx/5558/2/input/.swcrc
Normal file
22
crates/swc/tests/fixture/issues-5xxx/5558/2/input/.swcrc
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "ecmascript",
|
||||
"jsx": false
|
||||
},
|
||||
"target": "es5",
|
||||
"loose": false,
|
||||
"minify": {
|
||||
"compress": false,
|
||||
"mangle": false
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "es6",
|
||||
"strict": false,
|
||||
"strictMode": false,
|
||||
"lazy": false,
|
||||
"noInterop": false
|
||||
},
|
||||
"minify": false
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
bar(x = async () => await 1) {
|
||||
}
|
||||
}
|
32
crates/swc/tests/fixture/issues-5xxx/5558/2/output/index.js
Normal file
32
crates/swc/tests/fixture/issues-5xxx/5558/2/output/index.js
Normal file
@ -0,0 +1,32 @@
|
||||
import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
|
||||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
|
||||
import _create_class from "@swc/helpers/src/_create_class.mjs";
|
||||
import regeneratorRuntime from "regenerator-runtime";
|
||||
var Foo = function() {
|
||||
"use strict";
|
||||
function Foo() {
|
||||
_class_call_check(this, Foo);
|
||||
}
|
||||
_create_class(Foo, [
|
||||
{
|
||||
key: "bar",
|
||||
value: function bar() {
|
||||
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _async_to_generator(regeneratorRuntime.mark(function _callee() {
|
||||
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
||||
while(1)switch(_ctx.prev = _ctx.next){
|
||||
case 0:
|
||||
_ctx.next = 2;
|
||||
return 1;
|
||||
case 2:
|
||||
return _ctx.abrupt("return", _ctx.sent);
|
||||
case 3:
|
||||
case "end":
|
||||
return _ctx.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
}
|
||||
}
|
||||
]);
|
||||
return Foo;
|
||||
}();
|
@ -125,6 +125,9 @@ impl<C: Comments> VisitMut for Actual<C> {
|
||||
if m.function.body.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
m.visit_mut_children_with(self);
|
||||
|
||||
if m.kind != MethodKind::Method || !m.function.is_async {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user