Is there a conversion process for nullish coalescing operators, similar to how polyfills work?
When TypeScript is transpiled to JavaScript, nullish coalescing and other unsupported syntax will be converted based on the specified ES version in your tsconfig file.
For instance, in TypeScript:
obj.foo ?? 5;
will be transpiled to
"use strict";
var _a;
(_a = obj.foo) !== null && _a !== void 0 ? _a : 5;
Similarly, the exponentiation operator:
3 ** 5
will be transpiled to
Math.pow(3, 5);
if the target is ES2015 or earlier (since the exponentiation operator was introduced in ES2016). If the target is ES2016 or higher, it will not undergo transpilation.