Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information