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

[Feature Request]: Node.getProject() method #782

Closed
gregjacobs opened this issue Jan 16, 2020 · 4 comments
Closed

[Feature Request]: Node.getProject() method #782

gregjacobs opened this issue Jan 16, 2020 · 4 comments

Comments

@gregjacobs
Copy link

Hey @dsherret. I've come across a couple of scenarios where it would be convenient to be able to retrieve the Project instance from a SourceFile (such as to grab other source files in the project based on the given SourceFile's source).

I've been passing in both the Project and the SourceFile instances to functions that I write which need this ability, but figuring that having a SourceFile.getProject() method would be convenient (especially when one function calls another, and it ends up being a lot of functions that need both arguments).

Since this feature could be handy on any Node, was thinking to put this new method on that class. The method could just return this._context.project?

Thoughts?

Best,
Greg

@dsherret
Copy link
Owner

Sure. Do you want to do a PR and add it to Node? It would be very easy to do as you pointed out. I think this method should throw if the node was created with the createWrappedNode function though. Otherwise I would get to it soon.

@gregjacobs
Copy link
Author

Hey man, many apologies! I just realized that you commented on this issue way-back-when and I somehow missed it :X I totally would have raised that PR!

Thanks for adding the method though - will def help, and much appreciated!

@dsherret
Copy link
Owner

@gregjacobs that's no problem as it was simple to add! I'll release this over the weekend now that TS 3.8 is out.

@gregjacobs
Copy link
Author

Sounds good :) Thanks!

dsherret added a commit that referenced this issue Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants