Changelog: swc v1.2.60

Bugfixes#

super in decorated methods (#846)#

Previously swc emitted wrong code if a method call from super is used.

class SomeClass {
@dec
someMethod() {}
}
class OtherClass extends SomeClass {
@dec
anotherMethod() {
super.someMethod();
}
}

Codes like above now works properly.

dce: Fix for decorated classes (#1769)#

@decorator
class Class {}
function decorator(cls: any) {
console.log(cls.name);
}

Previously swc dropped a class if it's decorated and not instantiated. This is wrong because decorators can have side effects and now it's fixed.

bundler: Prevent hang (#1779)#

In certain complex import scenarios, the bundler of swc hanged while determinging cycle imports. This is now fixed and fairly complex imports are now handled by the bundler.

fixer: Binary expressions in unary operands (#1781, #1789)#

There was a regression related to parenthesis.

const n = ~~(Math.PI * 10);
const c = +(+1 / 4);
console.log(c);

These was miscompiled but it's now fixed.

Support for export * with same name (#1780)#

swc now supports code like

// constant.ts
export enum Foo {}
// File1.ts
export { Foo } from "./constant";
// file2.ts
export { Foo } from "./constant";

Fix for double imports (#1757)#

Previously swc throwed an error for double imports like

import "testlibrary";
import { aFunc } from "testlibrary";
console.log("aFunc: ", aFunc(1, 2));

It's now fixed.

Fix for async generator (#1752)#

Previously swc miscompiled await in async generators and codes like

async function* generate(): AsyncGenerator {
const results = await Promise.all([
Promise.resolve(1),
Promise.resolve(2),
Promise.resolve(3),
]);
for (const result of results) {
console.log(`yield ${result}`);
yield result;
}
}
async function printValues() {
const iterator = generate();
for await (const value of iterator) {
console.log(`iterator value: ${value}`);
}
}
printValues();

was broken. It's now fixed.