Commit 9a92ad1
authored
fix(compiler): add heritage clauses earlier in native transform (#4769)
This fixes an issue that surface in the stencil / ionic-framework
nightly tests, where a `super()` call was mistakenly omitted from native
components.
This was occurring after changing to use the `updateConstructor` helper
function in #4741 in the native transform. When that function updates
the constructor on a class it inspects the class declaration's heritage
clauses to determine if a `super()` call needs to be present in the
constructor, and adds one if needed.
In the native component transform, however, the transformer to add an
`extends HTMLElement` heritage clause and transform the constructor were
called separately and then combined into a single updated class
declaration using `updateComponentClass`. This meant that when the
`updateConstructor` function was called the class declaration node
didn't yet have a heritage function, so a `super()` call was not added.
This was addressed by a small refactor to the heritage clause insertion
function. Instead of creating and returning an updated heritage clause
it uses `ts.factory.updateClassDeclaration` to return an updated class
declaration node with an appropriate heritage clause added to it. This
updated class declaration is then passed to `updateConstructor` and a
`super()` call is correctly inserted.1 parent 9ee02c5 commit 9a92ad1
1 file changed
Lines changed: 14 additions & 7 deletions
Lines changed: 14 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
| |||
0 commit comments