You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The name field above also confuses some next stage build tools that don't support class fields yet, e.g. the popular acorn that is used by Svelte compiler (sveltejs/svelte#6592)
However, compiling with -t ES2021 produces more compact code without useless field declaration:
class MenuItem {
constructor(name) {
this.name = name;
}
}
🔎 Search Terms
constructor shorthand
🕗 Version & Regression Information
Version 4.3.5 & next
This changed between versions 4.2.x and 4.3.x
The text was updated successfully, but these errors were encountered:
Just to add because I feel this is important: in an environment that natively supports class fields, the declared field is not useless - behavior actually differs between the two snippets because ECMAScript dictates [[Define]] semantics for fields.
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.
Bug Report
Compiling this with
-t ESNext
produces:The name field above also confuses some next stage build tools that don't support class fields yet, e.g. the popular acorn that is used by Svelte compiler (sveltejs/svelte#6592)
However, compiling with
-t ES2021
produces more compact code without useless field declaration:🔎 Search Terms
constructor shorthand
🕗 Version & Regression Information
Version 4.3.5 & next
The text was updated successfully, but these errors were encountered: