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

Tracing diagnostics back to the original node

Open stuartc opened this issue 4 years ago • 1 comments

Hi there!

I have a bit of an unusual requirement, I've been trying to find a way to keep track of the original nodes provided before transforming - and then use ts-morph to typecheck those statements in a different context/wrapper.

ts-morph has unlocked a huge part of the solution in that the bindings get updated on ast modification :raised_hands: .

What I'm trying to achieve is providing feedback to less-technical users (who can still swing some code) without them having to setup imports and all sorts of boilerplate.

I've tried to detail the requirement as best I can over here: https://github.com/OpenFn/kiini/issues/2

Any recommendations on how ts-morph could help or any complimentary projects would be really appreciated.

stuartc avatar Jul 14 '21 14:07 stuartc

I think the only way to do this would be to use diagnostic.getStart() and diagnostic.getLength() then use sourceFile.getDescendantAtStartWithWidth(diagnostic.getStart(), diagnostic.getLength() to try to get the Node.

dsherret avatar Sep 26 '21 19:09 dsherret