-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Introduce and consume suppressLeadingAndTrailingTrivia #19135
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me, but I don't understand the relation between emitNode and node, so you should probably get another reviewer.
@@ -740,6 +740,8 @@ namespace ts.refactor.extractSymbol { | |||
} | |||
|
|||
const { body, returnValueProperty } = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)); | |||
suppressLeadingAndTrailingTrivia(body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if you create a fresh node that re-use tokens, do you suppressLeadingAndTrailingTrivia on the new node or the old node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed offline, you probably want to suppress it on the new node. Note that the token shouldn't appear in two places in the tree - that will mess up the positions. You have to make a copy.
|
@weswigham gave me the impression he knew about emit flags. Perhaps he'd like to confirm that I'm not abusing the system too badly? |
Nope, this is pretty much exactly what it is for and what we use it for inside transforms. |
Everyone's happy? |
Oh, also re @sandersn on the |
When a range is extracted, the leading and trailing trivia stays at the extraction site.
Fixes #18626