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

How can I get node location(Line, column)? #801

Closed
susiwen8 opened this issue Mar 28, 2020 · 2 comments
Closed

How can I get node location(Line, column)? #801

susiwen8 opened this issue Mar 28, 2020 · 2 comments
Labels

Comments

@susiwen8
Copy link

Hi , Great project you got here. I just want to know how can I get which line and column this node at original source file?

@dsherret
Copy link
Owner

Hey @susiwen8, it seems this currently only exists on the source file. On any node, do:

const lineAndColumn = node.getSourceFile().getLineAndColumnAtPos(node.getStart());

getStart() returns the first token pos within the node (excluding jsdocs... provide getStart(true) to get the start position with js docs)

@susiwen8
Copy link
Author

@dsherret Thanks getLineAndColumnAtPos is exactly what I need.

@dsherret dsherret reopened this Apr 3, 2021
@dsherret dsherret closed this as completed Apr 3, 2021
Repository owner locked and limited conversation to collaborators Apr 3, 2021
Repository owner unlocked this conversation Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants