Closed
Description
TypeScript Version: 3.6.0-dev.20190801
Search Terms:
destructuring, variable declatation, binding pattern, export, commonjs
Code
export const { x, ...rest } = { x: 'x', y: 'y' }
Expected behavior:
Similarly to array destructuring, make _a
a temporary local identifier:
var _a;
exports.x = (_a = { x: 'x', y: 'y' }, _a.x), exports.rest = __rest(_a, ["x"]);
Actual behavior:
exports._a = { x: 'x', y: 'y' }, exports.x = _a.x, exports.rest = __rest(_a, ["x"]);
Which fails at runtime because _a
is not defined.
Playground Link:
Related Issues: