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 does not generate interfaces for classes without added aggregations/props/events #368

Closed dfenerski closed 2 years ago

dfenerski commented 2 years ago

Consider the following class:

/**
 * @name com.namespace.SomeListItem
 */
export default class SomeListItem extends ColumnListItem {
    static readonly metadata = {
        library: 'com.namespace',
    };
    public firePress() {
        super.firePress();
        try {
            const jqRef = this.$();
            jqRef.removeClass('sapMPopinHovered');
        } catch (e) {
            console.error(e);
        }
        return this;
    }
}

The generator completely skips it, and when imported typescript remains blind for the constructor signatures.

Is this planned, should I add mock props, or maybe manually write declaration to be merged?

akudev commented 2 years ago

@dfenerski I haven't checked in detail, but right now I think you are right: because of the constructor signature the interface should also be generated when a class does not add anything to the interface. I'll check as soon as UI5con stress allows.

akudev commented 2 years ago

@dfenerski on second glance, what exactly is not working or missing?

When I e.g. use the app in the "custom-controls" branch of the hello word app and add another control which inherits from MyControl but does not specify any new properties etc., then its constructor works perfectly fine as far as I see. It just inherits the one from the parent class, as expected.

image

For reference: the code where such classes are ignored is here. In fact there is already a "FIXME" about exactly this topic, but right now it looks like this can just be removed.

dfenerski commented 2 years ago

@akudev you are right, it is working fine. I got confused because only generated props need an additional interface; instance methods do not due to standard import / export statements during devtime. Thanks for the responsiveness!