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 field initializers in constructor to class fields #288
Comments
Sorry, but I don't understand your question. Try to formulate your question as:
|
@nene I think what he meant with However private and public fields like the one he used |
OK. So as I understand it, given input like: function User() {
this.name = "Anonymous";
}
User.prototype.sayHi = function() {
alert(`Hello, ${this.name}!`);
} Lebab class User {
constructor() {
this.name = "Anonymous";
}
sayHi() {
alert(`Hello, ${this.name}!`);
}
} But you would instead expect to see: class User {
name = "Anonymous";
sayHi() {
alert(`Hello, ${this.name}!`);
}
} As @uniibu pointed out, class fields are currently a stage-3 proposal. I think it would be a nice feature to implement regardless, as the class fields feature is kinda widely used. Unfortunately the Espree parser which Lebab uses doesn't support this syntax yet. So first we'd have to switch to another parser like Babylon. I don't think I personally have much motivation to do this. But of course pull requests are always welcome. |
@nene espree is now acron based so it supports plugins so the syntax is supported |
It is possible to get latest JS conversion?
For Eg : without constructor and 'this' keyword
The text was updated successfully, but these errors were encountered: