vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
867 stars 58 forks source link

@JsonValue/@JsonCreate generates unknown type when value object extends generic base class #2499

Open peholmst opened 1 month ago

peholmst commented 1 month ago

Describe the bug

Given the following base class for value objects:

public abstract class SingleValueObject<T> {

    private final T value;

    public SingleValueObject(T value) {
        this.value = value;
    }

    public T value() {
        return value;
    }
}

And the following concrete implementation:

public final class TimeZone extends SingleValueObject<String> {

    @JsonCreator
    public TimeZone(String value) {
        super(value);
    }

    @Override
    @JsonValue
    public String value() {
        return value;
    }
}

When used like this:

public record LocationReference(
        @Nonnull TimeZone timeZone
) 

The generated TypeScript looks like this:

interface LocationReference {
    timeZone: unknown;
}
export default LocationReference;

Expected-behavior

The generated TypeScript should look like this (string instead of unknown):

interface LocationReference {
    timeZone: string;
}
export default LocationReference;

Reproduction

Create the classes described above in a project and generate the corresponding TypeScript types.

System Info

MacOS 14.5, Chrome 125.0.6422.114, Vaadin 24.5.0.alpha1.

Legioth commented 1 month ago

Potentially related to https://github.com/vaadin/hilla/issues/579