You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Writing MetadataOptions.properties.type function and object as ts types #406
Currently, when defining properties of type function or object, only these type unsafe definitions are accepted.
The ability to define more specific types would greatly improve the quality and readability of the code.
I have 2 ideas in my mind how this could be achieved.
The first would be a more type guess based aproach like the following:
staticreadonly metadata: MetadataOptions={properties: {someFunc: {type: "(button: sap.m.Button) => void"}}};// the .gen.d.ts would look like this:import{$ControlSettings}from"sap/ui/core/Control";importButtonfrom"sap/m/Button";declare module "./Example"{interface$ExampleSettingsextends$ControlSettings{callback?: (button: Button)=>void}// ... //}
The idea is to define them as type-safe TS types and convert them to the simple type with the transformation to js.
In the case of the example, the metadata would be rewritten to type: "function".
Alternatively, if guessing the type would be too difficult, since some object types can be very complex, enhancing the property with an additional key could make it easier and enable the useage of interfaces and named types:
Activity