Changelog: swc v1.1.11

AST#

TsExpressionWithTypeArguments#

TsExpressionWithTypeArguments has typeArguments instead of typeParams. This is technically breaking change, but I didn't bumped major version because I don't think the change break real world code.

Parser#

span of import / export (#540)#

Spans of import statements and export statements are fixed.

span of await in for-of statement (#551)#

Spans of await token in for-of statement is fixed.

readonly properties in class (#547)#

Previously,

class Foo {
readonly t: string;
}

was parsed as

class Foo {
t: string;
}

But from now on, it's correctly parsed as readonly.

import.meta (#545)#

swc now accepts

const test = import.meta.someProp;

and

import.meta.someProp;

Codegen#

default import with namespace (#546)#

Previously,

import availabilities, * as availabilityFunctions from "reducers/availabilities";

is printed as

import availabilities* as availabilityFunctions from 'reducers/availabilities';

which is wrong. It is now printed correctly as

import availabilities, * as availabilityFunctions from "reducers/availabilities";

indent after line comment (#544)#

It means,

function b() {
// comment
a = 1;
}

is preserved. Previously, indent after a line comment was removed.

Transforms#

regenerator (#554)#

transform-regenerator (from babel) is implemented in swc, and invoked automatically if you target es3 or es5.

whitespace after inner JSX tag is preserved (#542)#

let page = (
<p>
Click <em>New melody</em> listen to a randomly generated melody
</p>
);

is compiled as

var page = React.createElement(
"p",
null,
"Click ",
React.createElement("em", null, "New melody"),
" listen to a randomly generated melody"
);

instead of

var page = React.createElement(
"p",
null,
"Click ",
React.createElement("em", null, "New melody"),
"listen to a randomly generated melody"
);

which is wrong.