SAP/ui5-typescript

Controller extension issues when using typescript

heimwege opened this issue · 20 comments

I'm trying to switch a fiori elements odata v4 app to typescript and am facing the issue that the override objects need to be brought into the extend call, just like the metadata object for a control.
However even if that was ok, there is also a static function called override on the ControllerExtension type which will contradict with this definition and create type conflict that can only be resolved through a ts-ignore.

Do you have any guidance for this ?

Hi, We are also facing the same issue. Could you please provide any update on this.

Hi,
this is currently being discussed.
Bringing the override object into the extend call is a simple change in the transformer, but yeah, then there is the name clash.

For this clash we currently see 3 potential solutions:

  1. renaming/establishing a different name than "override" in UI5
  2. establishing a different name in TypeScript and convert the name to "override" in the mentioned transformer
  3. introducing decorators in TS

the pros and cons:

  1. Not nice to have a second name, might create confusion. We’re in favor of the name "overrides" for the metadata and "override" for the static API method.
    But we have no information, which variant of "override" is currently more in use outside. It depends a bit on that whether we prefer to rename the metadata part or the API part.
  2. Adding a 2nd name to the transpilation looks only like a temporary solution as it also will cause confusion and create a documentation problem when the documentation depends on the used programming language. Ideally, APIs should be consistent between JS runtime and TS world.
  3. As long as decorators are not settled in TC39, we tend not to adopt them as a public offering of UI5.

The UI5 core team is going to work on documenting extensibility in UI5 better. Insights from that work might help to decide between the options.

Regards
Andreas

Hi @akudev ,

any updates on this one?

Best Regards
Dominik

None that I heard of. :-(
I'll inquire.

Basically this is waiting on backlog items around the "controller extensions" topic in the core team. It is unclear when they will be addressed.

Hi @nlunets
was the reference to pull request 653 a mistake because it was deleted from the original comment or does 653 help with this issue as well?

It doesn't help as far as i know more than it confirm there is a problem :)

Option 1 (renaming with "overrides" for the metadata and "override" for the static API method) is the way to go. The necessary change in the transformer is on its way and the UI5 core team will work on allowing the new name "overrides" for the metadata.