The following code:
class A {
constructor(public x: number) {
}
}
Since TypeScript 3.7, which added the useDefineForClassFields configuration1, it is translated into the following result with "useDefineForClassFields": true (playground), up to the latest version (5.9.3):
"use strict";
class A {
x;
constructor(x) {
this.x = x;
}
}
esbuild currently (0.27.4) generates the following code (playground):
class A {
constructor(x) {
this.x = x;
}
}
I think we should stay consistent with TypeScript.
related: microsoft/TypeScript#55132