mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
* add new test case * opt: conditionally apply the flatten transform Only apply the flatten transform when the do expression contains Break/Continue/Return. This enables us to optimize the output since we don't have to memoize intermediate results. * update test outputs * remove unreachable code variable declaration within for in/of can not have initializer. * update test case to cover spread element * add more test cases for early exit scenario * make node 6 happy * revert complex variable declaration removal
21 lines
513 B
JavaScript
21 lines
513 B
JavaScript
class C {
|
|
constructor({ ...x }, readonly y) {
|
|
const z = do {
|
|
if (Object.keys(x).length > 0 && y) {
|
|
return (this.result = 'xy');
|
|
}
|
|
else if (Object.keys(x).length > 0) {
|
|
return (this.result = 'x');
|
|
}
|
|
else if (y) {
|
|
return (this.result = 'y');
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
expect(new C({ a: 1 }, 2).result).toBe('xy');
|
|
expect(new C({ a: 1 }, undefined).result).toBe('x');
|
|
expect(new C({}, 2).result).toBe('y');
|
|
expect(new C({}, undefined).result).toBe(undefined);
|