SAP / ui5-typescript

Tooling to enable TypeScript support in SAPUI5/OpenUI5 projects
https://sap.github.io/ui5-typescript
Apache License 2.0
201 stars 28 forks source link

[ts-interface-generator] Interface for ManagedObject based Class Instances #430

Closed BenReim closed 1 hour ago

BenReim commented 6 months ago

The ts-interface generator should consider cases in which not a class, but an instance is exported.

e.g. SampleManagedObject.ts


class SampleManagedObject extends ManagedObject {
...
}

export default new SampleManagedObject();

akudev commented 1 hour ago

Actually, this should already work (and does in my tests). The ts-interface-generator finds and enriches the class structures. Whether the class or an instance of it is exported, is an independent matter and whatever you export has the correct enriched structure. Also, the interface generation does happen no matter what exactly is exported.

This means in case your control file exports an instance instead of the class, like:

export default new SampleControl();

then the user can - as expected - write:

import SampleControl from "./SampleControl";
SampleControl.destroyTooltip();

Please let me know if there is still some gap I missed.