Changelog: swc v1.1.46

Bugfixes#

resolver: arrow expression (#790)#

swc had a bug that occurs if an arrow parameter and local binding has a same name. Due to the bug, code like

window.addEventListener("message", (e) => {
try {
console.log(e.data);
} catch (e) {
console.log(e);
}
});

was miscompiled. It is now fixed.

types in as expressions (#787)#

Previously, swc didn't detect type-only imports correctly if as is used. It means,

import { IPerson } from "../types/types";
export function createPerson(person: IPerson) {
const a = {} as IPerson;
}

was compiled as

import { IPerson } from "../types/types";
export function createPerson(person) {
const a = {};
}

instead of

export function createPerson(person) {
const a = {};
}

Fix was quite simple. By making swc drop type before visiting whole expression, typescript type casting expressions are now stripped out.