Changelog: swc v1.1.12

AST#

GetterProperty (#557)#

The code below is a valid typescript file.

const obj = {
get test(): string {
return "";
}
};

Now swc's GetterProperty has a field named typeAnnotation and swc can parse it correctly.

TsImportType (#560)#

Import type havs type arguments rather than type params.

Parser#

Thanks to @dsherret, may span-related bugs of parser is fixed.

Span of patterns (#558)#

Span of patterns are fixed.

Span of classes and interfaces (#566)#

Span of classes and interfaces are fixed.

Comments on last statement (#555)#

Previously comments before } was removed silently.

if (true) {
}
// 2

Wrong error messages are removed (#574)#

const fn = <T extends string | number>(x: T) => x;

is a valid typescript code. swc emitted an error like

error: TS1109
--> index.ts:1:30
|
1 | const fn = <T extends string | number>(x: T) => x;
|

The error is removed.

Transforms#

Nested if statement (#565)#

swc optimizes javascript file if possible. But there was a bug related to it.

if (x) {
if (y) log(1);
else if (z) log(2);
} else log(3);

was miscompiled as

if (x)
if (y) log(1);
else if (z) log(2);
else log(3);

From now, braces are correctly preserved and swc emits

if (x) {
if (y) log(1);
else if (z) log(2);
} else log(3);