Open iljapostnovs opened 2 years ago
@iljapostnovs If I don't miss anything, there is even already a pull request for this: https://github.com/SAP/ui5-typescript/pull/357
However, that one is stuck a bit, as such generic classes cannot be used as type of control (or ManagedObject) properties/aggregations etc. - the UI5 way of specifying them just doesn't allow it. As result, after merging that PR, one would be able to generate interfaces for classes with generics, but one could NOT use these classes in the metadata of another class (see https://github.com/SAP/ui5-typescript/pull/357#issuecomment-1146137512). And I don't see a proper way to overcome this at the time being.
What do you think, is this restriction one you (and most) could live with and is the overall feature still worth it? Or would it be a deal-breaker and too confusing when those classes cannot be used everywhere?
@iljapostnovs If I don't miss anything, there is even already a pull request for this: #357
However, that one is stuck a bit, as such generic classes cannot be used as type of control (or ManagedObject) properties/aggregations etc. - the UI5 way of specifying them just doesn't allow it. As result, after merging that PR, one would be able to generate interfaces for classes with generics, but one could NOT use these classes in the metadata of another class (see #357 (comment)). And I don't see a proper way to overcome this at the time being.
What do you think, is this restriction one you (and most) could live with and is the overall feature still worth it? Or would it be a deal-breaker and too confusing when those classes cannot be used everywhere?
@akudev, I understood the problem. The benefits of generics are far greater in my case. However, I do understand that it might confuse somebody. (Problem with inability to use generic classes at all might confuse somebody as well ;) ) The choice as for me looks like either "Please don't use generic classes" or "Please don't use generic classes in other class metadata". The second one looks much less restrictive if you ask me.
Hi @akudev,
I've found another issue with generics.
If class A
is extending e.g. ManagedObject
, class A
is generic class, interface for class A
is generated successfully, however, if class B
is extending class A
, nothing is generated for class B
.
Hi.
There is an issue when generating interfaces for generic classes. Example:
Generated interface:
As a result, error message is shown:
All declarations of 'MyGenericClass' must have identical type parameters
Which, basically, means, that generated interface should be:Would it be possible to add generics to the interface? Thanks!