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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,48 @@
1
1
# Changelog
2
2
3
+
## Unreleased
4
+
5
+
* Fix TypeScript-specific class transform edge case ([#3559](https://github.com/evanw/esbuild/issues/3559))
6
+
7
+
The previous release introduced an optimization that avoided transforming `super()` in the class constructor for TypeScript code compiled with `useDefineForClassFields` set to `false` if all class instance fields have no initializers. The rationale was that in this case, all class instance fields are omitted in the output so no changes to the constructor are needed. However, if all of this is the case _and_ there are `#private` instance fields with initializers, those private instance field initializers were still being moved into the constructor. This was problematic because they were being inserted before the call to `super()` (since `super()` is now no longer transformed in that case). This release introduces an additional optimization that avoids moving the private instance field initializers into the constructor in this edge case, which generates smaller code, matches the TypeScript compiler's output more closely, and avoids this bug:
8
+
9
+
```ts
10
+
// Original code
11
+
class Foo extends Bar {
12
+
#private = 1;
13
+
public: any;
14
+
constructor() {
15
+
super();
16
+
}
17
+
}
18
+
19
+
// Old output (with esbuild v0.19.9)
20
+
class Foo extends Bar {
21
+
constructor() {
22
+
super();
23
+
this.#private = 1;
24
+
}
25
+
#private;
26
+
}
27
+
28
+
// Old output (with esbuild v0.19.10)
29
+
class Foo extends Bar {
30
+
constructor() {
31
+
this.#private = 1;
32
+
super();
33
+
}
34
+
#private;
35
+
}
36
+
37
+
// New output
38
+
class Foo extends Bar {
39
+
#private = 1;
40
+
constructor() {
41
+
super();
42
+
}
43
+
}
44
+
```
45
+
3
46
## 0.19.10
4
47
5
48
* Fix glob imports in TypeScript files ([#3319](https://github.com/evanw/esbuild/issues/3319))
0 commit comments