Changelog: swc v1.1.8

Optional Chaining (#525)#

As this is stage 4, it's automatically enabled.

You can write code like

a?.b?.c;

in ecmascript too. Previously it was possible only in typescript.

Nullish coalescing (#526)#

As this is stage 3, you need to set jsc.parser.nullishCoalescing to true to use it.

swc can now handle ?? operator.

const someValue = myOtherValue ?? "default value";

is compield as

const someValue =
myOtherValue !== null && myOtherValue !== void 0
? myOtherValue
: "default value";

BigInt literals (#520)#

As this is stage 4, it's automatically enabled.

4n + 10n;

This is also usable from typescript without any additional configuration.

Numeric separators (#521)#

As this is stage 3, you need to set jsc.parser.numericSeparator to true to use it.

Long numeric literals can be written as

10_200;
0b10101_0001;
0xa0_b0_c0;

Comments improvements (#528)#

Comments on paren expressions are moved to inner expresssion correctly.

// bar
[
// foo
a,
//bar
(
//baz
b
)
];

is compiled as

// bar
[
// foo
a,
//bar
//baz
b
];