openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

initial typescript conversion

Open eldefay opened this issue 4 years ago • 12 comments

using https://github.com/eldefay/ui5-task-ts-migration

version: https://github.com/eldefay/ui5-task-ts-migration/commit/9d55f550f700acbdb866b334d5cb6aebdeac5cc4

TODO support export constructor as classes support local imports (sap.base.util => ../util)

eldefay avatar Oct 18 '21 11:10 eldefay

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 18 '21 11:10 CLAassistant

Involving @akudev and @petermuessig

codeworrior avatar Oct 18 '21 12:10 codeworrior

@codeworrior, does it mean that the UI5 code base is going to be converted to TypeScript and then modernized towards ES12+ (e.g. ES Modules, callbacks-free, async/await, and the rest of great features of the modern JavaScript)?

That could be a great Xmas present!

pubmikeb avatar Oct 21 '21 16:10 pubmikeb

@codeworrior, does it mean that the UI5 code base is going to be converted to TypeScript and then modernized towards ES12+ (e.g. ES Modules, callbacks-free, async/await, and the rest of great features of the modern JavaScript)?

That could be a great Xmas present!

I would not hold my breath on this. I am waiting for Openui5 to embrace Typescript since 2013.

But let's be positive: that day it will be something like all the X-Mas from them to now in a row and even more. Hope to still be among the living by then.

R

RobertoMalatesta avatar Oct 26 '21 18:10 RobertoMalatesta

@eldefay Thanks for the creating the custom task to migrate the UI5 projects to TypeScript - this is indeed interesting but also very ambitious. Right now, we have no plans to move the OpenUI5 codebase towards TypeScript. We rather work on providing the proper type definitions for the UI5 framework and the UI libraries on Definitely Typed and NPM as well as creating support to write UI5 applications and UI libraries in TypeScript. This is current work in progress - although we don't make fast improvements here, we step by step enable the TypeScript support for UI5 and improve the quality of our type definitions by fixing our APIs and JSDocs. Most probably you know the following already: https://blogs.sap.com/2021/07/01/getting-started-with-typescript-for-ui5-application-development/

Our current work might also allow an easier conversion to TypeScript in future. Although I personally don't think we will convert the framework, it is part of our roadmap to enable TypeScript development for and with UI5.

What I like about you custom tasks is, that even if it may not be used to convert the OpenUI5 codebase (we need to discuss this a bit further - @akudev, @codeworrior and I) it can be useful for migrating our module loading to ES modules. We already had discussed the options to move the UI5 code base closer to modern ES features - and the usage of ES modules and ES classes are some of the main topics here. Another interesting thing for today already might be the usage of your custom task to convert existing UI5 application or UI library projects to TypeScript. I need to take a deeper look into your custom task. I really like the core idea behind your PR! Really appreciated and thanks so much for sharing...

Please be patient with us - drastic changes always need to be properly prepared... 😉

petermuessig avatar Oct 28 '21 06:10 petermuessig

providing the proper type definitions for the UI5 framework and the UI libraries on Definitely Typed and NPM

Great, since currently the type inferring by the external IDEs is poor. I've tried a demo project on IDEA and got a lot of types-related warnings.

migrating our module loading to ES modules.

That's extremely important!

pubmikeb avatar Oct 28 '21 06:10 pubmikeb

@pubmikeb - thanks for the feedback having warnings in IDEA - I need to check this, what project did you use? I am usually using VSCode and sometimes still Eclipse 🤣 .

petermuessig avatar Oct 28 '21 06:10 petermuessig

@pubmikeb - thanks for the feedback having warnings in IDEA - I need to check this, what project did you use? I am usually using VSCode and sometimes still Eclipse 🤣 .

It's just a custom playground project where I test some UI5 techniques. If you want, I can prepare a sample project with repro of such issues.

pubmikeb avatar Oct 28 '21 07:10 pubmikeb

@pubmikeb - that would be great if you can do that once you have time. 👍

petermuessig avatar Oct 28 '21 07:10 petermuessig

that would be great if you can do that once you have time.

@petermuessig, I've prepared a sample project. In App.controller.js I observe:

28_232559

Of course, @types/openui5 is enabled in File | Settings | Languages & Frameworks | JavaScript | Libraries:

28_233146

IDEA 2021.3 EAP 6

pubmikeb avatar Oct 28 '21 21:10 pubmikeb

(any readers, please refer to the discussion in https://github.com/SAP/openui5/issues/3403 regarding the ~5 comments above)

akudev avatar Dec 03 '21 12:12 akudev

Thanks @akudev - unfortunately, I missed to follow up the topic here. Still have it on my agenda. I see there is some progress in the discussion #3403.

petermuessig avatar Dec 03 '21 16:12 petermuessig

@petermuessig, is there any update on the subject?

pubmikeb avatar Nov 21 '22 14:11 pubmikeb

Hi @pubmikeb ,

we want to discourage the usage of the globals and therefore prefer the usage of the ESM types for adding the code completion support to your UI5 JS development. Recently we had a question about the JS code completion for UI5: https://answers.sap.com/questions/13733371/broken-code-completion-in-bas.html - Gregor Wolf mentioned issues in the code completion. Therefore, we recommend the usage of the types from @types/openui5 and @openui5/ts-types-esm should be used.

@akudev enhanced one of our sample project to use the ESM types for the JS code completion and explained how the JSDoc should be written. Basically you can benefit from the same quality of the code completion like for TS but it comes with additional JSDoc comments in your code which makes it a bit verbose: https://github.com/SAP-samples/ui5-cap-event-app/blob/js-with-typescript-support/README.md

Best regards, Peter

petermuessig avatar Nov 23 '22 07:11 petermuessig

Thanks a lot @eldefay for this PR. With the https://github.com/SAP/ui5-typescript project we are able to provide a typescript scenario for UI5 consumers.

To migrate the existing code base of UI5 is currently not planned and will not happen in near feature. Technically, it will be possible that some libraries migrate over time but thats something what the dedicated library teams can decide on their own. Therefore I close this PR. Thanks a lot for the interesting discussion all about this topic here.

flovogt avatar Jun 16 '23 07:06 flovogt