Commit 7bc07b5
committed
feat(ts-interface-generator): add types for event parameters and events
Event parameters of controls etc. are now available as types named like
"<ControlName>$<EventName>EventParameters" and the events themselves as
"<ControlName>$<EventName>Event". The respective event-related methods
make use of these events, so for consumers there is now full type
support regarding the events of controls developed with this
interface-generator.
ONE CAVEAT:
The generated types make use of the fact that sap.ui.base.Event is a
class with generics since version 1.115 of the UI5 types. For use with
lower versions of the UI5 types, the generator can create a kind of shim
that makes the Event class generic. This happens automatically based on
the version of the UI5 types AT CONTROL DEVELOPMENT TIME (i.e. only when
the control developer uses a version of the UI5 types lower than 1.115).
If, however, the application developer USING the control uses a
different version of the UI5 types than the control developer, then the
following happens:
1.) App uses >=1.115, Control uses < 1.115: the shim is there but does
not hurt.
2.) App uses <1.115, Control uses >= 1.115: the shim is missing and the
generated *.gen.d.ts file is not valid in the context of the app's UI5
types. However, TypeScript simply makes the type "any", so there there
is no big problem on application side, only reduced type safety.
Furthermore, "skipLibCheck" needs to be set to "true", otherwise the
TypeScript compiler reports an error when checking the UI5 types and the
generated interface files.
Tested to work in TS 4.7 (at least) up to 5.1.
fix #3991 parent 22a6ad7 commit 7bc07b5
File tree
7 files changed
+1915
-1357
lines changed- packages/ts-interface-generator
- src
- test
- testdata/sampleControl
7 files changed
+1915
-1357
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
0 commit comments