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

Convert getter / setter to member functions #800

Open
automatensalat opened this issue Jan 26, 2023 · 0 comments
Open

Convert getter / setter to member functions #800

automatensalat opened this issue Jan 26, 2023 · 0 comments
Labels
✨ Feature New refactoring or feature

Comments

@automatensalat
Copy link
Contributor

Is this request related to a problem? Please describe.

I'm currently refactoring a class that exposes data via a getter:

class A {
  get someStuff() {
    return "hello";
  }
}

// somewhere else:
let a = new A();
let stuff = a.someStuff;

Describe the solution you'd like

I'd like a refactoring that converts the get accessor to a function. It should also convert the usages of the getter to proper function calls. After the refactoring:

class A {
  someStuff() { // <--
    return "hello";
  }
}

// somewhere else:
let a = new A();
let stuff = a.someStuff(); // <-- 

I suppose it could also work with set accessors, although I suppose that would be harder to do:

class A {
  set someStuff(a) {
    this.stuff = a;
  }
}
let a = new A();
a.stuff = "hello" 

// after refactoring:

class A {
  setSomeStuff(a) {
    this.stuff = a;
  }
}
let a = new A();
a.setSomeStuff("hello")
@automatensalat automatensalat added the ✨ Feature New refactoring or feature label Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature New refactoring or feature
Projects
None yet
Development

No branches or pull requests

1 participant