Skip to main content

Changelog: swc v1.2.64

· 3 min read

To see full list of patches, please visit


Optional chaining (#1882)#

Previously swc had a bug related to nested optional chaining expressions.

const button = renderedView.find(LoadingButton);button?.prop('onClick')?.({} as any);

Fixed by @kwonoj and by #1899.

Visitor bug (#1886)#

The type definition for object patterns were wrong and it's fixed by #1900.

codegen: private static properties (#1898)#

Export default function with async (#1799)#

Previously if you target old version and use async function in a named export default function-s, swc didn't create a variable with same name.

Affected code looks like

import React from "react";
export default function Foo() {  return (    <div      onClick={async (e) => {        await doSomething();      }}    ></div>  );}
Foo.displayName = "Foo";

Fixed by #1900.

optional chaining with single-line arrow (#1836)#

Previously code like

function bug() {  const arrowFn = (arg) => this.object[arg]?.();}

was broken because variables are wrongly injected.

Fixed by #1900.

decorator (#1278)#

swc now initializes decorators right before they are applied.

This change allows referencing the class from decorator.

type Klass<T = any> = { new (...args: any[]): T };function MyDecorator(klass: Klass): PropertyDecorator {  return () => {    // do something    console.log(klass);  };}
class MyClass {  @MyDecorator(MyClass) prop: "";}
console.log(new MyClass());

Fixed by #1905.

regenerator: Exeception (#1892)#

Old versions of swc incorrectly throwed an error for a specific code.

Fixed by @kwonoj and by #1906

regenerator: Respect module config (#1641)#

swc now emits dependency for regenerator-runtime as es import statement, which is technically wrong but works because bundlers handle it.

regenerator: unused codes (#1687)#

Previously swc emitted useless codes.

Fixed by #1909.

typeof undefined (#1843)#

Previously swc could break a program if it uses typeof in specific way.

Fixed by #1909.

proper helpers (#1682)#

Previously module transforms were too naive and as a result could break some code.

Fixed by #1909

export * with named overrides (#1714)#

swc now allows overriding export * with named exports.

Code like below will work properly.

import { customRender } from "./customRender";
// re-export everythingexport * from "@testing-library/react";
// override render methodexport { customRender as render };

decorators for class properties (#1913)#

Previsouly swc could break codes like

import { action } from "mobx";
class Store {  constructor() {    this.doSomething();  }
  @action  doSomething = () => {    console.log("run");  };}
const store = new Store();

Fixed by @IronLu233 and by #1914.

await expressions as callee#

Previously swc could break code like

new (await foo())();

Fixed by #1919.