-
Notifications
You must be signed in to change notification settings - Fork 7
Runtime call generation #1
Comments
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: 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. |
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 :
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 ;-) |
@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. |
@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. |
Closing... This repository is being archived. Now the ui5ts package is maintained at https://github.com/neoprincie/ui5ts |
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?
The text was updated successfully, but these errors were encountered: