2

UI5 Library TypeScript Generator

 1 year ago
source link: https://blogs.sap.com/2022/10/11/ui5-library-typescript-generator/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
October 11, 2022 2 minute read

UI5 Library TypeScript Generator

0 2 110

Introduction

When building UI5 apps you will need to develop a custom UI5 control sooner or later. Doing this requires (or at least it is recommended to do so) to bundle those UI5 controls in a library. With TypeScript support for UI5 you do not only develop UI5 apps in TypeScript but most likely also UI5 Controls and libraries. For kickstarting your UI5 library and UI5 control there was no TypeScript generator yet, until now 😊.

Based on this TypeScript UI5 Library demo repository of Andreas Kunz and the already existing UI5 Library generator of Geert-Jan Klaps, I was able to create a TypeScript version of the UI5 Library generator.

TypeScript UI5 Libray and Control demo repo from Andreas: https://github.com/SAP-samples/ui5-typescript-control-library

UI5 Library generator of Geert-Jan: https://blogs.sap.com/2021/01/24/kickstart-your-ui5-library-development-with-the-ui5-library-generator/

Installation

The new TypeScript UI5 Library generator can be used from in the “Easy UI5” Generator, so you first have to install Yeoman:

npm i -g yo

The generator can be started with the following command:

yo easy-ui5 ts-library

Or just by selecting from the Yeoman menu:

image1.png

Generate

In the “Easy UI5”  generator you’ll find “ts-library”:

image2.png

Answer all questions:

image3.png

Once all is completed, it will generate the library and immediately start installing all npm dependencies. In case npm start results in an error, try running npm install again.

In the end, you’ll have the following project generated to kickstart developing UI5 Controls in TypeScript:

image4.png

All config files are generated following the recommendations of SAP.

Run the command “npm run start” to test the library:

image5.png

This will open the test page to see your control:

image6.png

With this you should be good to go for building UI5 controls and Libraries with TypeScript!

Feel free to provide feedback or add improvements by using pull requests on the GitHub repo of the UI5 TypeScript Library generator: https://github.com/ui5-community/generator-ui5-ts-library


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK