Transpile
Convert transpiled syntax back to modern JavaScript.
default-parameters
https://babeljs.io/docs/babel-plugin-transform-parameters
js
function f() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var y = arguments.length > 1 ? arguments[1] : undefined;
}
function f(x = 1, y) {}
logical-assignments
https://babeljs.io/docs/babel-plugin-transform-logical-assignment-operators, TypeScript and SWC
js
x || (x = y)
x ||= y
js
var _x, _y;
(_x = x)[_y = y] && (_x[_y] = z);
x[y] &&= z;
nullish-coalescing
js
a !== null && a !== undefined ? a : b;
a ?? b;
js
var _a$b;
(_a$b = a.b) !== null && _a$b !== undefined ? _a$b : c;
a.b ?? c;
js
function foo(foo, qux = (_foo$bar => (_foo$bar = foo.bar) !== null && _foo$bar !== undefined ? _foo$bar : "qux")()) {}
function foo(foo, qux = foo.bar ?? "qux") {}
nullish-coalescing-assignment
js
a ?? (a = b);
a ??= b;
js
var _a;
(_a = a).b ?? (_a.b = c);
a.b ??= c;
optional-chaining
js
a === null || a === undefined ? undefined : a.b;
a?.b;
js
var _a;
(_a = a) === null || _a === undefined ? undefined : _a.b;
a?.b;
template-literals
https://babeljs.io/docs/babel-plugin-transform-template-literals
js
"'".concat(foo, "' \"").concat(bar, "\"")
`'${foo}' "${bar}"`