[[module (tsconfig)|module]]や[[target (tsconfig)|target]]に`es2020`が指定できるようになった。
たとえば以下のコードについて、[[ES2020]]から導入された[[オプショナルチェーン (JavaScript)]]を使ってみる。
`main.ts`
```ts
interface Hoge {
huga?: {
poyo?: {
value: number;
};
};
}
declare let hoge: Hoge;
const num = hoge?.huga?.poyo?.value;
```
[[target (tsconfig)|target]]をそれぞれ`es2019`、`es2020`で[[トランスパイル]]すると結果は以下の様に変わる。
`es2019`
```js
"use strict";
var _a, _b;
const num = (_b = (_a = hoge === null || hoge === void 0 ? void 0 : hoge.huga) === null || _a === void 0 ? void 0 : _a.poyo) === null || _b === void 0 ? void 0 : _b.value;
//# sourceMappingURL=main.js.map
```
`es2020`
```js
"use strict";
const num = hoge?.huga?.poyo?.value;
//# sourceMappingURL=main.js.map
```