vojtechhabarta / typescript-generator

Generates TypeScript from Java - JSON declarations, REST service client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generic type Date/Instant not converted to DateAsString

sphinks opened this issue · comments

Hi! I faced an issue with generic type including Instant. It does not convert properly to DateAsString by builtin functionality.

public class BaseClass<T> {

    private T field1;
    private T field2;
}

public class ChildClass extends BaseClass<Instant> {
...
}

After TS is generated I get such code:

export interface ChildClass extends BaseClass<Date> {
    field1: DateAsString | null;
    field2: DateAsString | null;
}
...
export interface BaseClass<T> {
    field1: T | null;
    field2: T | null;
}

For some reason type in parent class declaration was not switched to DateAsString and Date type is unknown. The only way I managed to workaround it - use custom mapping to map date to string directly, but not use DateAsString type in a middle:

<customTypeMappings>
    <mapping>
        java.time.Instant:string
    </mapping>
</customTypeMappings>