Skip to content

Instantly share code, notes, and snippets.

@dsherret
Last active December 4, 2020 03:31
Show Gist options
  • Save dsherret/826fe77613be22676778b8c4ba7390e7 to your computer and use it in GitHub Desktop.
Save dsherret/826fe77613be22676778b8c4ba7390e7 to your computer and use it in GitHub Desktop.
import { tsquery } from "@phenomnomnominal/tsquery";
import { Node } from "ts-morph";
export function query(node: Node, query: string) {
return tsquery(node.compilerNode, query)
.map(n => (node as any)._getNodeFromCompilerNode(n) as Node);
}
@dsherret
Copy link
Author

dsherret commented Jun 8, 2018

This is untested, but should work. Also, I'm using an internal method here so it may break in the future.

@dsherret
Copy link
Author

dsherret commented Nov 11, 2018

@cancerberoSgx this internal method name is breaking in 18.1.0. It now has an underscore prefix.

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