google / google/closure-compiler

ES6 transpilation of spread causes CollapseProperties to back off in some cases

Open
#2,066 7 comments 0 reactions 0 assignees View on GitHub
ES6
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

For instance, if you have an array of numbers and you call `goog.math.average(...nums)` this translates to (roughly) `goog.math.average.apply(goog.math, nums)` because the ES6 transpilation pass doesn't know that goog.math.average doesn't care what its `this` value is, so it doesn't know that `goog.math.average.apply(null, nums)` would have worked just as well. Then we get a warning "incomplete alias created for namespace goog.math" and CollapseProperties fails to collapse that namespace as well as it otherwise would have.

Maybe we write a pass that goes through after transpilation and replaces the `goog.math` with `null` when we know that can be done safely.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.