google / google/closure-compiler
prototype assignments create side-effects
Open
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Given this input:
```js
export function makeDecorator(name, parentClass) {
function DecoratorFactory(objOrType) {}
DecoratorFactory.prototype = Object.create(parentClass.prototype);
DecoratorFactory.prototype.toString = () => `@${name}`;
return DecoratorFactory;
}
function Parent() {}
const foo = makeDecorator('foo', Parent);
```
We should tree-shake away everything to 0, but we don't:
https://goo.gl/fqmTHt
Note that commenting out the two lines with `.prototype` does tree-shake.
/cc @mhevery
Contributor guide
Assessment
This issue has not been assessed yet.