Skip to content

ts-interface-generator: interface is not generated in multiple scenarios #337

Closed

Description

@iljapostnovs

ts-interface-generator version: 0.4.0

Interface for ManagedObject children is not generated:
image

Interface for second+ level children of Control is not generated:
image

image

Activity

  1. self-assigned this
    on Feb 16, 2022
  2. akudev commented on Mar 9, 2022

    @akudev
    Member

    Hi Ilja,
    thanks for the issue report!
    I just fixed it, so this issue will be gone with the next release. But #338 is not addressed yet.

    Note that type "number" is not allowed for UI5 properties, only "int" or "float" - see https://ui5.sap.com/#/api/sap.ui.base.ManagedObject%23methods/sap.ui.base.ManagedObject.extend

    Thanks and regards
    Andreas

  3. iljapostnovs commented on Mar 10, 2022

    @iljapostnovs
    Author

    Hi @akudev,

    Thanks a lot!

    Note that type "number" is not allowed for UI5 properties, only "int" or "float" - see https://ui5.sap.com/#/api/sap.ui.base.ManagedObject%23methods/sap.ui.base.ManagedObject.extend

    Yeah, silly mistake by me. I was aware of that, but I guess my data typing was "typescripted" away for this issue :)

  4. akudev commented on Mar 22, 2022

    @akudev
    Member

    The next release has been created now (0.4.1).

  5. iljapostnovs commented on Mar 22, 2022

    @iljapostnovs
    Author

    Hi @akudev,
    Thanks for letting me know!

    I'm receiving an error for this case using v0.4.1:
    image

    \ui5-typescript-helloworld\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:97
                                    throw new Error(`${statement.name ? statement.name.text : ""} inherits from ${interestingBaseClass} but the parent class ${typeChecker.getFullyQualifiedName(type.getSymbol())} seems to have no settings type`);
                                    ^
    
    Error: OneMoreControl inherits from Control but the parent class "/ui5-typescript-helloworld/src/control/MyControl".MyControl seems to have no settings type
        at \ui5-typescript-helloworld\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:97:39
        at Array.forEach (<anonymous>)
        at \ui5-typescript-helloworld\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:69:46
        at Array.forEach (<anonymous>)
        at \ui5-typescript-helloworld\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:67:43
        at Array.forEach (<anonymous>)
        at getManagedObjects (\ui5-typescript-helloworld\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:63:27)
        at generateInterfaces (\ui5-typescript-helloworld\node_modules\@ui5\ts-interface-generator\dist\interfaceGenerationHelper.js:39:17)
        at \ui5-typescript-helloworld\node_modules\@ui5\ts-interface-generator\dist\generateTSInterfaces.js:133:60
        at Array.forEach (<anonymous>)
    
  6. akudev commented on Mar 23, 2022

    @akudev
    Member

    Hi @iljapostnovs,
    I see... the generator tries to find the settings type of the parent class (to make its own settings type inherit from it). The settings type can only be found in the constructor signatures.
    The problem is that at this time the parent class (MyControl) does not have any constructors yet. You know, the constructors are suggested in the console output of the generator and need to be added by hand. In the situation you showed, there is already the suggested output for MyControl constructors:

    NOTE:
    Class MyControl in file [c:/.../git/ui5-typescript/packages/ts-interface-generator/src/test/testdata/testControl/MyControl.ts]() needs to contain the following constructors, in order to make TypeScript aware of the possible constructor settings. Please copy&paste the block manually, as the ts-interface-generator will not touch your source files:
    ===== BEGIN =====
    // The following three lines were generated and should remain as-is to make TypeScript aware of the constructor signatures
    constructor(idOrSettings?: string | $MyControlSettings);
    constructor(id?: string, settings?: $MyControlSettings);
    constructor(id?: string, settings?: $MyControlSettings) { super(id, settings); }
    ===== END =====

    Once the suggested constructors are added to MyControl, the next run of the generator does succeed. This is what I would suggest as temporary workaround.

    I'm not sure whether the scenario is likely to happen - at least when MyControl is developed first, the constructors should already be added in the beginning and then creating OneMoreControl will succeed just fine. But apparently you encountered the scenario. Maybe the hint to add the constructors should be made clearer. Or maybe not doing so should result in an error?

    But of course I can also try to handle this case. After all, all the way up the chain there is a UI5 base class with well-defined settings type. Might be a bit tricky, though, to get there in this stage of the generation, orthogonal to the regular flow... I'll have to check.
    A first improvement could be to mention this possibility and workaround in the error message.

    Thanks for reporting! I opened #346 to track it separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ts-interface-generatorRelated to the ts-interface-generator sub-package

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions