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

Add section "return multiple nodes" #4

Merged
merged 6 commits into from
Jan 3, 2020

Conversation

bendtherules
Copy link
Contributor

@bendtherules bendtherules commented Jan 3, 2020

Part of #2.
Added doc and example.

@bendtherules bendtherules changed the title return-multiple-node - Add example to duplicate statements return-multiple-node - Add example to duplicate expression statements Jan 3, 2020
@bendtherules bendtherules changed the title return-multiple-node - Add example to duplicate expression statements Add section "return multiple nodes" Jan 3, 2020
// If it is a expression statement,
if (ts.isExpressionStatement(node)) {
// Clone it
const newNode = ts.getMutableClone(node);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

watch out for this - ts-loader doesn't play nicely (theres a section at the bottom of the handbook that mentions this). only found this out yesterday hehe

could you re-do this with either updateExpressionStatement or just returning the node twice?

[node, node]

@itsdouges
Copy link
Owner

love it, just the one comment

@bendtherules
Copy link
Contributor Author

Done.

I hope ts-loader supports it well in the future. Although it works here, little concerned with moving a node around without cloning as it contains reference to its position in the source file and such.

@itsdouges itsdouges merged commit da6b0bd into itsdouges:master Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants