3 ms·
I've had it generate some verbose stuff when using .?, along these lines: (_c = this.log) === null || _c === void 0 ? void 0 : _c.withIndent(' ', () =>
by tom_ 3y ago
I've had it generate some verbose stuff when using .?, along these lines:
(_c = this.log) === null || _c === void 0 ? void 0 : _c.withIndent(' ', () => {
var _a;
// (pointless ?. silence eslint)
(_a = this.log) === null || _a === void 0 ? void 0 : _a.pn(`Buffer address: 0x${utils.hex8(bufferAddress)} `);
});
This was originally this:
this.log?.withIndent(' ', () => {
// (pointless ?. silence eslint)
this.log?.pn(`Buffer address: 0x${utils.hex8(bufferAddress)} `);
});
If you have a long chain of ?., perhaps it gets really ugly.
- madeofpalk 3y agoRight - if you use a language feature that is newer than your compile target, it will compile down 'modern' syntax like that. I'm not sure what else you would expect.
- tom_ 3y agoThe discussion topic was cases where the js output includes a bunch of extra junk, so this is just intended as an example of that! Mostly the output looks pretty much like the input. (The compile target in my case is ES2017, as configured in August 2018. I can probably update that.)
- vundercind 3y agoOh no, they’ve added more features JS doesn’t actually support. Enums were one thing, this was… an extremely bad idea. I hope it’s not a sign they’re gonna move farther into being a separate language. [edit] oh no wait that’s in newer JS versions, you’re just “compiling” to a version that doesn’t support it. Update your target to a version that supports the feature you used and it should be fine.
- fallingsquirrel 3y agoIt's just downleveling the syntax so it runs in browsers that are too old to support `?.` (similar to what Babel would do). If you set your compile target to es2020 or later it will emit `?.` verbatim.