vojtechhabarta / typescript-generator

Generates TypeScript from Java - JSON declarations, REST service client
MIT License
1.15k stars 236 forks source link

Support generic parameter default type #1003

Open FlorianCassayre opened 1 year ago

FlorianCassayre commented 1 year ago

We are designing some custom extensions for our project, and one them relies on the generic parameter default type feature of Typescript. For example:

interface Test<T = string> {}

The current API of typescript-generator regarding generics is the following:

public static class GenericVariableType extends BasicType {
    public GenericVariableType(String name) {
        super(name);
    }
}

As you can see it is not possible to provide a default type, therefore we would like to request this functionality in the API.

Luckily the following workaround works (although it looks dirty):

new TsType.GenericVariableType("T = string")
FlorianCassayre commented 1 year ago

I think a similar comment can be made about type bounds, I am not sure if these are supported either.

olegshtch commented 1 year ago

I did PR to support bounds but it wasn't accepted.