bublejs / buble

https://buble.surge.sh
MIT License
870 stars 67 forks source link

Getters and setters with computed names emit invalid code #69

Open adrianheine opened 6 years ago

adrianheine commented 6 years ago
obj = {
  get [x] () { return 1 },
  set [x] (value) { valueSet = value }
};

emits

obj = {};
objget [x] = () { return 1 };
objset [x] = (value) { valueSet = value };
adrianheine commented 6 years ago

See also #20 about getters and setters in general.

nathancahill commented 6 years ago

I think the only way to support this concisely is by using Object.defineProperty which isn't supported in IE8.

nathancahill commented 6 years ago

Would still be better than invalid code.

adrianheine commented 6 years ago

We could just bail if target is IE8 and we try to transpile getters or setters.

adrianheine commented 5 years ago

Note that in class bodies computed getters and setters throw an error, and I implemented my last suggestion in 9d0e728e507c4bfb73f0aaacf465f7b265a17b66.