Last active
December 4, 2020 03:31
-
-
Save dsherret/826fe77613be22676778b8c4ba7390e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is untested, but should work. Also, I'm using an internal method here so it may break in the future.