[Feature Request]: Add ImportDeclaration.removeNamedImport() method
See original GitHub issueHey @dsherret, long time! Happy holidays!
I’m implementing a script where I’d like to “move” named imports from one ImportDeclaration
to another in a source file, and I realized that it would be useful to have an ImportDeclaration.removeNamedImport(name)
method.
Seems the only way to remove a particular named import at this time is to use removeNamedImports()
in conjunction with addImports()
to remove all and then re-add the ones that should remain.
Thoughts?
Best, Greg
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How To Add A Feature Request Form to Your Product
In this post, we'll take a look at how you can easily add a form to your product and start to collect feedback...
Read more >How to Submit a NEW Feature Request - YouTube
Through the Project Insight community help center you can submit a new request to be added to the tool. This is diferent than...
Read more >Submiting a Feature Request - Help Center
NOTE: Customers can provide valuable feedback on product improvements and tool additions by submitting feature requests. Submit a Feature Request. Step 1: On ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah I totally missed that
namedImport.remove()
!I feel like I’ve missed that in the past too, but it’s been a while since I got to play with ts-morph so I forgot about it again, lol.
I guess from an API perspective, my thinking was that if I’m able to add new named imports via the parent node, it would seem to me that I could also remove named imports via the parent node. I didn’t look any further than that 😕 Does make sense though - one needs to target the particular named import they’re looking for to be able to remove it.
Just wanted to thank you again though for your excellent library! It’s so useful to have these abstractions above the compiler API, while also being able to edit original source files in a way that maintains the original formatting/comments/etc. I’ve used ts-morph (and previously ts-simple-ast 😄) on 3 separate projects now and it’s always come through!
All good man, thanks so much! Good luck with the new project!