I am looking for a tool or IDE that can help automatically refactor JavaScript or TypeScript function into a class.
It would be nice if it can take care of this
keyword in a safe way but is not a requirement. I can also fix remaining issues manually afterwards.
The purpose I want to use it for, is easy migration/maintenance of a legacy code.
Example
Before:
function MyService(dependency) {
function privateMethod() {}
function publicMethod() {
privateMethod();
}
return {
publicMethod,
}
}
After:
class MyService() {
constructor(dependency) {}
private privateMethod() {}
public publicMethod() {
this.privateMethod();
}
}