* 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
24 lines
536 B
JavaScript
24 lines
536 B
JavaScript
const state1 = {};
|
|
expect(function() {
|
|
const a = "str";
|
|
state1.getA = () => a;
|
|
|
|
--a;
|
|
}).toThrow('"a" is read-only');
|
|
expect(state1.getA()).toBe("str"); // Assignment did not succeed
|
|
|
|
const state2 = {};
|
|
expect(function() {
|
|
const b = {
|
|
valueOf() {
|
|
state2.valueOfIsCalled = true;
|
|
}
|
|
};
|
|
state2.b = b;
|
|
state2.getB = () => b;
|
|
|
|
--b;
|
|
}).toThrow('"b" is read-only');
|
|
expect(state2.getB()).toBe(state2.b); // Assignment did not succeed
|
|
expect(state2.valueOfIsCalled).toBe(true); // `bar` was read before error thrown
|