Skip to content
This repository has been archived by the owner on Jun 22, 2019. It is now read-only.

Runtime call generation #1

Closed
nathanss opened this issue Oct 18, 2017 · 5 comments
Closed

Runtime call generation #1

nathanss opened this issue Oct 18, 2017 · 5 comments

Comments

@nathanss
Copy link

I am currently looking for a way of leveraging TypeScript's advantages on UI5 applications and found your repo.

The only drawback on your method seems to be that the necessary code to call sap.ui.define is generated at runtime. Isn't there a way of generating the equivalent *.js file already with the right call to "sap.ui.define"?

Have you had other experiences using UI5 with TypeScript?

@lmcarreiro
Copy link
Owner

lmcarreiro commented Oct 18, 2017

To do that, it would probably need to change the TypeScript compiler. Create another module system (as another option instead of "amd" or "commonjs").

I think you can call sap.ui.define by yourself, samething like this:

sap.ui.define(["sap/ui/core/mvc/Controller"], (Controller: typeof sap.ui.core.mvc.Controller) => Controller.extend("yournamespace.YourClass", {
    onInit(): void {
        this.yourMethod();
    },
    yourMethod(): void {
        //your method body
    }
}));

But this way, you would not get intellisense working for your own classes outside each one of them, unless you create definition .d.ts files for them.

Some people have talked about other solutions here:
SAP/openui5#88

I think it wouldn't be hard to create a Gulp plugin to convert AMD define calls (generated by TypeScript) into an UI5 sap.ui.define call.

@o0Djeen0o
Copy link

Hi @lmcarreiro,

I was also thinking of moving to Typescript for some time to leverage our devs with UI5.

However the runtime requirement with your proposal is a no-go for me, as :

  • we do not have access to the bootstrap application (index.html) and do not want to pollute the context for others (we are in the context of multiple apps in a launchpad env developed by multiple teams).

It is why for me making such changes must be done at compilation time. I will probably do a small POC with babel to move the generated Typescript to POUI5 (that's a funny name), but never played with it, so I probably won't be really good at it. If I make some progress I will provide it there.

Thanks for taking time to improve our lives with UI5 ;-)

@lmcarreiro
Copy link
Owner

lmcarreiro commented Nov 14, 2017

@o0Djeen0o, @nathanss, Have you ever seen the Henry Li's babel plugin? https://github.com/MagicCube/babel-plugin-ui5

You could use TypeScript, target it to compile to ES2015 and use this plugin to convert your js code (generated by TypeScript compiler) to SAPUI5/OpenUI5 sap.ui.define calls.

In this case, you won't need my ui5ts npm package.

@r-murphy
Copy link

@lmcarreiro Thanks for this ts plugin. I just finished converting a couple UI5 apps to TS.

I have a fork of MagicCube's plugin which I can confirm work well with TypeScript and has a good set of features and options.
https://github.com/r-murphy/babel-plugin-transform-modules-ui5

@lmcarreiro
Copy link
Owner

Closing... This repository is being archived. Now the ui5ts package is maintained at https://github.com/neoprincie/ui5ts

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants