-
Notifications
You must be signed in to change notification settings - Fork 93
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
feat(convert-outputs): add migrations for new output() function #301
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 12ae362. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 3 targetsSent with 💌 from NxCloud. |
cc @joshuamorony you may like this too 😄 |
); | ||
} else { | ||
node.replaceWithText(newProperty.print()); | ||
// remove old class property Output |
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.
after node.replaceWithText(newProperty.print());
this code is needed for something like 'this.someOutput.next() to be replaced with this.someOutput.emit()' as this was actually possible on EventEmiter
newProperty.findReferencesAsNodes().forEach((reference) => {
try {
//we are looking for something like 'this.someOutput.next() as we want to replace it with this.someOutput.emit()'
//for each identifier we go someOutput, this.someOutput , then DotNotation , then Indentifier and we check that this identifier is 'next'
const nextIdentifier = reference
.getParentIfKindOrThrow(SyntaxKind.PropertyAccessExpression)
.getNextSiblingIfKindOrThrow(SyntaxKind.DotToken)
.getNextSiblingIfKindOrThrow(SyntaxKind.Identifier);
if (nextIdentifier.getText() === 'next') {
if (
nextIdentifier
.getParent()
.getParent()
.isKind(SyntaxKind.CallExpression)
) {
console.log(
nextIdentifier.getParent().getParent().getText(),
);
console.log('\nFOUND next - replacng with emit');
nextIdentifier.replaceWithText('emit');
}
}
} catch (err) {}
});
I have large project that I'm migrating so I will be adding coments like this if you are ok with it with next things that I stumbled on
now working on types as EventEmitter() is typed EventEmitter but output() is OutputEmitterRef, also found usages of accessing valueChanges on eventEmitters etc so will take care of those as well
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.
of course here simple regex could be used but I feel like this is much safer in terms of migration
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.
Hello @kbrilla
Thanks for all this 🙌🙏
Would you mind send a PR that we can merge into this PRs branch?
And then we can merge this PR into main and cut a release?
Added migration support for: