Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dts-generator): huge update to the currently used generator, plus update dependencies #438

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run hooks:commit-msg
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run hooks:pre-commit
10 changes: 8 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
demos/
packages/dts-generator/api-report/
packages/dts-generator/dist/
packages/dts-generator/src/checkDtslint/dtslintConfig/openui5-tests.ts
packages/dts-generator/src/resources/core-preamble.d.ts
packages/dts-generator/temp/
packages/ts-interface-generator/dist/
test-packages/
packages/ts-interface-generator/src/test/testdata/sampleControl/SampleControl.gen.d.ts
packages/ts-interface-generator/src/test/testdata/sampleControl/SampleControl.ts
packages/ts-interface-generator/src/test/testdata/sampleManagedObject/SampleManagedObject.gen.d.ts
packages/ts-interface-generator/src/test/testdata/sampleManagedObject/SampleManagedObject.ts
packages/ts-interface-generator/src/test/testdata/sampleManagedObject/SampleAnotherManagedObject.gen.d.ts
packages/ts-interface-generator/src/test/testdata/sampleManagedObject/SampleAnotherManagedObject.ts
packages/ts-interface-generator/src/test/testdata/sampleManagedObject/SampleAnotherManagedObject.ts
packages/ts-interface-generator/src/test/testdata/sampleWebComponent/SampleWebComponent.gen.d.ts
test-packages
9 changes: 4 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This is managed automatically via https://cla-assistant.io/ pull request voter.
### pre-requisites

- [Yarn](https://yarnpkg.com/lang/en/docs/install/) >= 1.4.2
- A [Long-Term Support version](https://nodejs.org/en/about/releases/) of node.js
- A current [Long-Term Support version](https://nodejs.org/en/about/releases/) of node.js
- (optional) [commitizen](https://github.com/commitizen/cz-cli#installing-the-command-line-tool) for managing commit messages.

### Initial Setup
Expand Down Expand Up @@ -46,21 +46,20 @@ It is recommended to use `git cz` to construct valid conventional commit message

[Prettier](https://prettier.io/) is used to ensure consistent code formatting in this repository.
This is normally transparent as it automatically activated in a pre-commit hook using [lint-staged](https://github.com/okonet/lint-staged).
However, this does mean that dev flows that do not use a full dev env (e.g editing directly on github)
may result in voter failures due to formatting errors.
However, this does mean that dev flows that do not use a full dev env (e.g editing directly on github) may result in voter failures due to formatting errors.

### Compiling

See the respective sub-packages for instructions (if needed at all).

### Testing

[Mocha][mocha] and [Chai][chai] are used for unit-testing
[Mocha][mocha] and [Chai][chai] are used for unit-testing.

[mocha]: https://mochajs.org/
[chai]: https://www.chaijs.com

- To run the tests execute `yarn test` in a specific sub-package.
- To run the tests, execute `yarn test` in a specific sub-package.
- Note that not all sub-packages contain tests.

### Full Build
Expand Down
34 changes: 10 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<p align="center">
:construction: Work in Progress! :construction:
</p>

[![Continuous Integration](https://github.com/SAP/ui5-typescript/actions/workflows/ci.yml/badge.svg?event=push)](https://github.com/SAP/ui5-typescript/actions/workflows/ci.yml)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![REUSE status](https://api.reuse.software/badge/github.com/SAP/ui5-typescript)](https://api.reuse.software/info/github.com/SAP/ui5-typescript)
Expand All @@ -15,14 +11,9 @@ This tooling can enable:
- Using TypeScript compiler to perform type checks on UI5 application code.
- More easily implementing UI5 applications and controls in TypeScript thus enjoying the general benefits of TypeScript.

Learn more about the general benefits of TypeScript here:

- https://stackoverflow.com/a/35048303
- https://channel9.msdn.com/posts/Anders-Hejlsberg-Introducing-TypeScript

It currently contains two public packages:

- [@ui5/dts-generator](./packages/dts-generator) [![npm-ui5-dts-generator][npm-ui5-dts-generator-image]][npm-ui5-dts-generator-url] A low level generator which transforms the UI5 api.json format to TypeScript definition (`*.d.ts`) file format.<br> <b>NOTE: the sources in this repository and also the package released at npm represent an outdated version of the generator tool, not the one used for the new improved TypeScript definition files which are released since June 2021. The code of the new generator version is planned to be released here later as well.</b>
- [@ui5/dts-generator](./packages/dts-generator) [![npm-ui5-dts-generator][npm-ui5-dts-generator-image]][npm-ui5-dts-generator-url] A generator which transforms the UI5 `api.json` format to TypeScript type definition (`*.d.ts`) format. This is useful to enable the type-safe usage of a UI5 control library written in JavaScript in code that uses TypeScript.

- [@ui5/ts-interface-generator](./packages/ts-interface-generator) [![npm-ui5-ts-interface-generator][npm-ui5-ts-interface-generator-image]][npm-ui5-ts-interface-generator-url] A tool supporting control development in TypeScript. It is used at development time and generates type definitions for the control API methods which are only created at runtime by the UI5 framework.

Expand All @@ -33,14 +24,7 @@ It currently contains two public packages:

## How to obtain the UI5 TypeScript signatures?

The UI5 type signatures are created and published as part of the UI5 build process. There are <b>two flavors</b> of the type definitions right now:

1. the legacy flavor which defines all entities with their global names, like `sap.m.Button`. As using globals is discouraged, using this flavor should be avoided. The definition packages are named `ts-types`.
2. the "ES modules" flavor which defines ES6-style module names for the entities. These definition support using modern JavaScript syntax with ES modules and classes, but require an additional transformation step, which can be run together with the anyway required TypeScript compilation. These recommended definition packages are simply named `types` (used to be `ts-types-esm` before release 1.113).

Both flavors are available for SAPUI5 as well as OpenUI5.

Using the modern definitions for SAPUI5 as example, the type definitions can be obtained like this:
The UI5 type signatures are created and published as part of the UI5 build process. They are available for SAPUI5 as well as OpenUI5. The SAPUI5 type definitions can be obtained like this:

With npm

Expand All @@ -50,20 +34,22 @@ With Yarn

`yarn add @sapui5/types --dev`

> **NOTE:** the type definitions define ES6-style module names for the entities. They require the usage of modern JavaScript syntax with ES modules and classes, which requires an additional transformation step that can be run together with the anyway required TypeScript transpilation.
>
> Before the type definitions were generated in ES module style, they did declare all APIs with their global names, which are discouraged to be used and will no longer be available in UI5 2.x. The dts-generator still has the capability to generate this legacy "globals" version of the type definitions, for compatibility reasons. These legacy definitions are released as "ts-types" instead of "types", but will no longer be produced for UI5 2.x.

Find all information about using UI5 with TypeScript at https://sap.github.io/ui5-typescript!

## Usage

To see the basic suggested project setup for TypeScript development with the new `types` packages, please check out the [TypeScript Hello World app](https://github.com/SAP-samples/ui5-typescript-helloworld). It not only can serve as copy template, but also includes a [detailed step-by-step guide](https://github.com/SAP-samples/ui5-typescript-helloworld/blob/main/step-by-step.md) for creating this setup from scratch.
To see the suggested project setup for TypeScript development with the `types` packages, please check out the [TypeScript Hello World app](https://github.com/SAP-samples/ui5-typescript-helloworld). It not only can serve as copy template, but also includes a [detailed step-by-step guide](https://github.com/SAP-samples/ui5-typescript-helloworld/blob/main/step-by-step.md) for creating this setup from scratch.

The [TypeScript branch of the "UI5 CAP Event App"](https://github.com/SAP-samples/ui5-cap-event-app/tree/typescript) sample demonstrates a slightly more complex application, using the same setup. It comes with an [explanation](https://github.com/SAP-samples/ui5-cap-event-app/blob/typescript/docs/typescript.md) of what UI5 TypeScript code usually looks like and what to consider.

Overall, the best resource for using UI5 with TypeScript is https://sap.github.io/ui5-typescript.
As mentioned, the best resource for using UI5 with TypeScript is https://sap.github.io/ui5-typescript.

See the [demos](./demos) directory for consumption examples of the legacy signatures.

## Status

This project is in an experimental **_Beta State_**. Significant changes are likely to occur, including potential **breaking changes**. More details and why you should not be afraid of this can be found [here](https://sap.github.io/ui5-typescript/beta-statement.html).

## Support

For issues caused by the generators please open [issues](https://github.com/SAP/ui5-typescript/issues) on GitHub.<br>
Expand Down
16 changes: 0 additions & 16 deletions demos/demo-js/CHANGELOG.md

This file was deleted.

116 changes: 0 additions & 116 deletions demos/demo-js/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions demos/demo-js/lib/constructor-signatures.js

This file was deleted.

14 changes: 0 additions & 14 deletions demos/demo-js/lib/define-deps-declarations.js

This file was deleted.

11 changes: 0 additions & 11 deletions demos/demo-js/lib/deprecation-information.js

This file was deleted.

15 changes: 0 additions & 15 deletions demos/demo-js/lib/inherited-methods.js

This file was deleted.

13 changes: 0 additions & 13 deletions demos/demo-js/lib/instance-methods.js

This file was deleted.

11 changes: 0 additions & 11 deletions demos/demo-js/lib/method-chaining.js

This file was deleted.

14 changes: 0 additions & 14 deletions demos/demo-js/lib/optional-parameters.js

This file was deleted.

16 changes: 0 additions & 16 deletions demos/demo-js/lib/static-attributes.js

This file was deleted.

10 changes: 0 additions & 10 deletions demos/demo-js/lib/static-inherited-methods.js

This file was deleted.

Loading
Loading