Closed akudev closed 9 months ago
The high-level approach here is:
routing: Routing
is just a type assignment, the import of Routing
just imports a type and appears unneeded from TS perspective. Hence, now the pre()
hook is used to get a list of all initially present imports.@controllerExtension
comment or decorator (and confirmed by looking at their structure) and converted to a value assignment (that is needed at runtime).
When using a controller extension in your own controller as a kind of mix-in, UI5 currently expects in the "extend" config object the extension class to be assigned to a property.
In TypeScript, however, the TS compiler must see the property being typed with an instance of the extension class, so subsequent calls to the extension can be written like they should (this.routing.doSomething()).
This change introduces the "@transformControllerExtension" comment and decorator which triggers a special kind of transformation for annotated class properties. The controller extension type assigned to the subsequent class property is then assigned as class in the extend object in JavaScript. And this assignment is not moved into the constructor like it normally would be.
Fixes https://github.com/SAP/ui5-typescript/issues/420