overlookmotel f166b7ae58
Fix plugin-transform-block-scoping const violations (#13248)
* Fix plugin-transform-block-scoping const violations

Fixes #13245

* Replace `a++` with `+a` where const violation

* Remove assignment where const violation

* Remove assignment for `&&=`, `||=`, `??=` where const violation

* Shorten test
2021-05-03 11:47:25 -04:00

21 lines
479 B
JavaScript

const state1 = {};
expect(function() {
const a = 3;
state1.getA = () => a;
a = 7;
}).toThrow('"a" is read-only');
expect(state1.getA()).toBe(3); // Assignment did not succeed
const state2 = {};
expect(function() {
const a = 3;
let b = 0;
state2.getA = () => a;
state2.getB = () => b;
a = b++;
}).toThrow('"a" is read-only');
expect(state2.getA()).toBe(3); // Assignment did not succeed
expect(state2.getB()).toBe(1); // `b++` was evaluated before error thrown