google / google/closure-compiler
ES6+ to ES5 transpilation should disallow get name() and set name() properties
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Take the following example:
```
class Foo {
get name() {
return "bar";
}
}
```
This transpiles to: ([link](https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540language_out%2520ES5%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F%252F%2520ADD%2520YOUR%2520CODE%2520HERE%250Aclass%2520Foo%2520%257B%250A%2520%2520%2520%2520get%2520name%28%29%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520return%2520%2522bar%2522%253B%250A%2520%2520%2520%2520%257D%250A%257D%250A%250A))
```
var Foo=function(){};
$jscomp.global.Object.defineProperties(Foo , {
name: {
configurable: !0,
enumerable: !0,
get: function() {
return "bar"
}
}
});
```
This is technically incorrect ES5, since the name property is not supposed to be configurable. According to [this](https://github.com/ariya/phantomjs/issues/13895), this might break PhantomJs. We found this issue internally after a Safari 9 iPad threw the following error:
`TypeError: Attempting to change configurable attribute of unconfigurable property.` (I could not reproduce this error outside of our testing environment, so I'm guessing this is a browser quirk).
Contributor guide
Assessment
This issue has not been assessed yet.