SAP / ui5-typescript

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

ts-interface-generator does not parse properties of type `Array` properly #370

Closed dfenerski closed 2 years ago

dfenerski commented 2 years ago

Consider the following class:

import ComboBox from 'sap/m/ComboBox';

/**
 * @name my.namespace.MyComboBox
 */
export default class MyComboBox extends ComboBox {
    static readonly metadata = {
        library: 'my.namespace',
        properties: {
            filters: {
                type: 'sap.ui.model.Filter[]',
                defaultValue: [],
            }
        },
    };
}

The MyComboBox.gen.d.ts file has then this auto-generated line: import Filter[] from "sap/ui/model/Filter[]";, i.e. when the aggregation is of type Something[], the generator considers the characters [ and ] to be part of the name.

dfenerski commented 2 years ago

There is warning from the generator when this occurs: image

akudev commented 2 years ago

Well, in general it is better to use an aggregation of Elements instead of an array property, so changes within the array/list also trigger invalidation, but yeah, in some cases arrays are needed, so this needs to be fixed. Thanks for reporting!

akudev commented 2 years ago

I've just fixed it, so it will be in the next release of the tool (some time after UI5con). Thanks again!

dfenerski commented 2 years ago

Thank you and sorry for the continued spam in the Eve of UI5Con ^^.

akudev commented 2 years ago

FYI: the "next release" (0.5.1) was done this week.