question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request]: Add ImportDeclaration.removeNamedImport() method

See original GitHub issue

Hey @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:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gregjacobscommented, Dec 19, 2019

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!

0reactions
gregjacobscommented, Jan 16, 2020

All good man, thanks so much! Good luck with the new project!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found