-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JS EmitThe issue relates to the emission of JavaScriptThe issue relates to the emission of JavaScript
Milestone
Description
TypeScript Version: 3.2.4
Search Terms: object rest, rest symbols
Code
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
const object = { visible: true };
Object.defineProperty(object, 'does not appear', {
enumerable: false,
value: 'hidden key',
});
Object.defineProperty(object, Symbol('appears on rest'), {
enumerable: false,
value: 'hidden symbol',
});
// does not include non-enumerable symbol or key
console.log({ ...object });
const { visible, ...rest } = object;
// includes non-enumerable symbol, but excludes key
console.log(rest);Expected behavior:
Non-enumerable symbols are not include in Object rest operations.
Actual behavior:
Non-enumerable symbols are included in Object rest operations.
Playground Link:
Related Issues:
I believe this was introduced with this PR => #12248.
This included Symbols in rest, but uses Object.getOwnPropertySymbols without using Object.prototype.propertyIsEnumerable check in the loops. You can see this in the generated output in the playground above.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JS EmitThe issue relates to the emission of JavaScriptThe issue relates to the emission of JavaScript