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:
Playground
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.
TypeScript Version: 3.2.4
Search Terms: object rest, rest symbols
Code
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:
Playground
Related Issues:
I believe this was introduced with this PR => #12248.
This included Symbols in rest, but uses
Object.getOwnPropertySymbolswithout usingObject.prototype.propertyIsEnumerablecheck in the loops. You can see this in the generated output in the playground above.