microsoft / TypeScript Public
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Way of specifying non-enumerable properties #9726
Comments
|
Seems like kind of an edge case; I wouldn't want to have to think about this for every .d.ts file for the sake of a couple of APIs |
|
I'd like to see the |
|
Might be useful for making Would help fix this old issue: #18133 |
|
Even if it can't be on interfaces, it would still be useful for classes to have by default. |
Just want to take the opportunity to point out that with a |
|
This issue is often referenced as an example of unsoundness of typescript. I wouldn't say it's an edge case as switching from objects to maps, array to sets are popular refactorings and at the same time usage of spreads with arrays and objects are ubiquitous. Shouldn't we prioritize this? |
|
@RyanCavanaugh Any update on the Typescript team's thinking on this? Right now it's pretty painful to work around this. |
|
Hi everyone
Just to share an example that is not an edge case. Our team has lost time debugging a problem caused by this, while Typescript was perfectly happy with the code: The problem was that spreading a I hope this helps to get a better perspective on this problem. Thanks! |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Object assign is defined like below in TS:
Though from MDN it is only copying members that are enumerable:
So if
Uabove has non-enumerable members, TS will copy them anyway. This is slightly incorrect and unsafe.One issue I recently ran into was
I was assuming I was copying all members of the
Selectionobject to{}:Though it didn't copy any members at all, because the
Selectionobject only contains non-enumerable members.Proposal
Mark properties as non-enumerable
And have an operator to get the only "enum side" of a type:
The text was updated successfully, but these errors were encountered: