Incorrect DCE of assignment to destructered parameter field with ES_2015 or higher
See original GitHub issueCode 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:
- Created 4 years ago
- Reactions:1
- Comments:9 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lauraharker
Any update on this issue?
It forces us to introduce Babel into our pipeline to transpile spread operators before passing Closure Compiler.
Sorry about that, I’ll reopen this issue.
link to your original repro