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
+46Lines changed: 46 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,52 @@
15
15
16
16
With this release, esbuild can now parse these new type parameter modifiers. This feature was contributed by [@magic-akari](https://github.com/magic-akari).
17
17
18
+
* Improve support for `super()` constructor calls in nested locations ([#2134](https://github.com/evanw/esbuild/issues/2134))
19
+
20
+
In JavaScript, derived classes must call `super()` somewhere in the `constructor` method before being able to access `this`. Class public instance fields, class private instance fields, and TypeScript constructor parameter properties can all potentially cause code which uses `this` to be inserted into the constructor body, which must be inserted after the `super()` call. To make these insertions straightforward to implement, the TypeScript compiler doesn't allow calling `super()` somewhere other than in a root-level statement in the constructor body in these cases.
21
+
22
+
Previously esbuild's class transformations only worked correctly when `super()` was called in a root-level statement in the constructor body, just like the TypeScript compiler. But with this release, esbuild should now generate correct code as long as the call to `super()` appears anywhere in the constructor body:
23
+
24
+
```ts
25
+
// Original code
26
+
class Foo extends Bar {
27
+
constructor(public skip = false) {
28
+
if (skip) {
29
+
super(null)
30
+
return
31
+
}
32
+
super({ keys: [] })
33
+
}
34
+
}
35
+
36
+
// Old output (incorrect)
37
+
class Foo extends Bar {
38
+
constructor(skip = false) {
39
+
if (skip) {
40
+
super(null);
41
+
return;
42
+
}
43
+
super({ keys: [] });
44
+
this.skip = skip;
45
+
}
46
+
}
47
+
48
+
// New output (correct)
49
+
class Foo extends Bar {
50
+
constructor(skip = false) {
51
+
var __super = (...args) => {
52
+
super(...args);
53
+
this.skip = skip;
54
+
};
55
+
if (skip) {
56
+
__super(null);
57
+
return;
58
+
}
59
+
__super({ keys: [] });
60
+
}
61
+
}
62
+
```
63
+
18
64
## 0.14.30
19
65
20
66
* Change the context of TypeScript parameter decorators ([#2147](https://github.com/evanw/esbuild/issues/2147))
0 commit comments