ts-morph icon indicating copy to clipboard operation
ts-morph copied to clipboard

[Question] query nested nodes

Open ArielGueta opened this issue 5 years ago • 1 comments

Thanks for this great library.

I'm wondering if there is any way to query nested children. If we take the following code:

someObject.someKey.someMethod()

And I want to get a reference to the someMethod Identifier. Currently, I need to perform many for loops to get this node.

Is there any easy way to do it with your library?

Thanks.

ArielGueta avatar Nov 24 '20 05:11 ArielGueta

I think the closest thing is to use tsquery. See here: https://gist.github.com/dsherret/826fe77613be22676778b8c4ba7390e7

There's some past discussion in #585 and #351, but basically adding querying is something I don't want to do, though probably having better support for what's shown in that gist would be nice (so it's not using an internal method).

dsherret avatar Dec 04 '20 03:12 dsherret