Skip to content

@ui5/ts-interface-generator: add generics to generated interface #376

@iljapostnovs

Description

@iljapostnovs

Hi.

There is an issue when generating interfaces for generic classes. Example:

import ManagedObject from "sap/ui/base/ManagedObject";

/**
 * @namespace com.ts.test.tstest.util
 */
export default abstract class MyGenericClass<T> extends ManagedObject {
	static readonly metadata: object = {
		properties: {
			test: "string"
		}
	}
}

Generated interface:

import { PropertyBindingInfo } from "sap/ui/base/ManagedObject";
import { $ManagedObjectSettings } from "sap/ui/base/ManagedObject";

declare module "./MyGenericClass" {

    /**
     * Interface defining the settings object used in constructor calls
     */
    interface $MyGenericClassSettings extends $ManagedObjectSettings {
        test?: string | PropertyBindingInfo;
    }

    export default interface MyGenericClass {

        // property: test
        getTest(): string;
        setTest(test: string): this;
    }
}

As a result, error message is shown: All declarations of 'MyGenericClass' must have identical type parameters
Which, basically, means, that generated interface should be:

export default interface MyGenericClass<T> {

        // property: test
        getTest(): string;
        setTest(test: string): this;
    }

Would it be possible to add generics to the interface?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestts-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