google / google/closure-compiler

prototype assignments create side-effects

Open
#2,206 10 comments 0 reactions 0 assignees View on GitHub
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

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.