Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add second parameter to getParentWhile condition #669

Closed
Validark opened this issue Jul 30, 2019 · 1 comment · Fixed by #670
Closed

add second parameter to getParentWhile condition #669

Validark opened this issue Jul 30, 2019 · 1 comment · Fixed by #670

Comments

@Validark
Copy link
Contributor

Validark commented Jul 30, 2019

Builds off: #107

Being able to call node.getParentWhile(p => ts.TypeGuards.etc(p) || etc) is very nice. However, I would like to be able to easily check whether the node under it has the proper relationship to the current parent. For example, let's say I want to figure out whether something is in the conditional of an if statement:

node.getParentWhile((p, n) => ts.TypeGuards.isIfStatement(p) && p.getExpression() === n)

Where:

  • n is the current node which starts as node in the above example
  • p is the current parent which starts as node.getParent() in the above example
@dsherret
Copy link
Owner

@Validark that sounds like a good idea. Would you like to implement it? If not, I'll get to it sometime soon.

Validark added a commit to Validark/ts-morph that referenced this issue Jul 30, 2019
@dsherret dsherret added this to the Version 4.0 milestone Sep 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants