Skip to content
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

remove PropertyAssignament from ObjectLiteralExpression #342

Closed
cancerberoSgx opened this issue Jun 5, 2018 · 6 comments
Closed

remove PropertyAssignament from ObjectLiteralExpression #342

cancerberoSgx opened this issue Jun 5, 2018 · 6 comments

Comments

@cancerberoSgx
Copy link
Contributor

Hello, before throwing myself to the water and implement it, I would like to know if there is some way of removing a PropertyAssignament from an ObjectLiteralExpression, example:

given an object literal {name: 'seba', lastname: 'gurin'}

and I want to remove property 'name' so the resulting object is {lastname: 'gurin'}

Thanks in advanced

@dsherret
Copy link
Owner

dsherret commented Jun 5, 2018

Nope. Looks like that was never implemented (same for ShorthandPropertyAssignment and SpreadAssignment). It looks like that would be a good one to implement and add .remove() methods on them. Thanks for checking 😄

@cancerberoSgx
Copy link
Contributor Author

thanks! nice to know - will PR then.

Idea / suggestion - from my point of view (user manipulating the AST) exporting removeChildren() (/src/manipulation/manipulations/removal.ts) would give a lot of flexibility. I know is low level - and I know is one more signature to maintain backwards compatibility - but this would be very very useful for advanced users . These things could be exported in a "lowLevel" namespace or something like that to not disturb common users :P .. the same applies to other utilities in manipulations/ my two cents.

@cancerberoSgx
Copy link
Contributor Author

aside question - I feel like there should be a couple extra interfaces for this kind of artificialities. For example, Removable (for this case), StructureFillable (fill), StructureGetable (getStructure) (and a couple more that I can't remember now), Also typeguards for those would be nice. I wonder if you agree with this....

@dsherret
Copy link
Owner

dsherret commented Jun 5, 2018

I'd rather implement it for the scenario and have people submit pull requests/report an issue when something's not implemented. That way everyone can benefit. Additionally, there can be a lot of edge cases and exposing removeChildren would just lead to people opening bug reports when it doesn't work the way they expect it to.

@cancerberoSgx
Copy link
Contributor Author

#343

@dsherret
Copy link
Owner

dsherret commented Jun 9, 2018

I missed a few things in the review so did a new commit. This should be good to go so I'm doing a release now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants