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

Create fields of members without dependencies #359

Open
github-nilsson opened this issue Apr 30, 2024 · 1 comment
Open

Create fields of members without dependencies #359

github-nilsson opened this issue Apr 30, 2024 · 1 comment

Comments

@github-nilsson
Copy link

It would be great if lebab could identify and move class member properties with constant initializations to fields automatically. I.e.

function A(b) {
  this.a = [];
  this.b = b;
}

would become

class A {
  a = [];
  constructor(b) {
    this.b = b;
  }
}
@nene
Copy link
Collaborator

nene commented May 3, 2024

Yeah, that would be nice. But it would have to be a separate transform as it's both a stylistic preference and IIRC member fields aren't part of the older ECMAScript classes spec.

Probably best to first perform the class transform and then apply this one already on top of a class.

But I'm not really doing any new developments on this library... so unless somebody does a pull request, this likely won't get implemented.

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

No branches or pull requests

2 participants