ui5-community / babel-plugin-transform-modules-ui5

A Babel transformer plugin for OpenUI5/SAPUI5. It allows you to develop UI5 applications by using the latest ECMAScript or TypeScript, including new syntax and objective oriented programming technology.
MIT License
33 stars 16 forks source link

feat: support using predefined controller extensions #120

Closed akudev closed 9 months ago

akudev commented 9 months ago

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

akudev commented 9 months ago

The high-level approach here is: