question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect DCE of assignment to destructered parameter field with ES_2015 or higher

See original GitHub issue

Code sample:

function installBaa({ obj }) {
    obj.baa = 'foo';
}

const obj = {};
installBaa({ obj });
console.log(obj.baa);

Command:

java -jar compiler.jar --js test.js -O ADVANCED --language_out ECMASCRIPT_2015

Version: v20191027

Expected output: (as output by --language_out ECMASCRIPT5)

console.log({a:"foo"}.a);

Actual output:

'use strict';console.log({}.a);

It looks like CC is losing the assignment when the target language is ECMASCRIPT_2015 or higher.

The following non-destructered parameter works as expected:

function installRoutes(x) {
    x.obj.baa = 'foo';
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
WearyMonkeycommented, Jan 29, 2020

@lauraharker

Any update on this issue?

It forces us to introduce Babel into our pipeline to transpile spread operators before passing Closure Compiler.

0reactions
lauraharkercommented, Aug 18, 2020

Sorry about that, I’ll reopen this issue.

link to your original repro

Read more comments on GitHub >

github_iconTop Results From Across the Web

ES2015 Destructuring & More - Medium
ES2015 Destructuring doesn't have to be scary, and in this post we'll go in-depth as to how it works, the various patterns you...
Read more >
JSDoc support for array destructuring #1970 - GitHub
Currently there is no simple way to annotate destructured array parameters. I propose a syntax similar to the current destructured objects ...
Read more >
Typing Destructured Object Parameters in TypeScript
ECMAScript 2015 allows a function to immediately destructure an object parameter. Here's the TypeScript syntax for typing the destructured ...
Read more >
typescript - Destructured parameter properties in constructor
In ECMAScript, destructuring assignment results in variables in variables (not properties than properties) receiving the component values.
Read more >
@swc/helpers | Yarn - Package Manager
SWC (stands for Speedy Web Compiler ) is a super-fast TypeScript / JavaScript compiler written in Rust. It's a library for Rust and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found