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

exposing Node#_getNodeFromCompilerNode

Open hugebdu opened this issue 3 years ago • 3 comments

Is there a reason not to make it public? createWrappedNode alternative creates contextless nodes (typechecker, lang service, ...).

Thanks!

hugebdu avatar Mar 06 '22 13:03 hugebdu

There is a very high chance of mis-use (ex. providing an out of date node). I should make all these methods actually private.

dsherret avatar Mar 06 '22 14:03 dsherret

David, thanks for your reply.

in that case maybe it is possible for createWrappedNode to accept additional argument (maybe project?: Project) and return a first-class instance of Node?

hugebdu avatar Mar 06 '22 15:03 hugebdu

Thinking about it more, I think we could expose this method, but the public one would do some additional checks on the provided compiler node to make sure it's still valid. The internal one doesn't for performance reasons.

dsherret avatar Mar 06 '22 15:03 dsherret