hilla icon indicating copy to clipboard operation
hilla copied to clipboard

Entity becomes non-generic if the generic parameter has boundary

Open Lodin opened this issue 6 months ago • 1 comments

Describe the bug

For the following endpoint:

@BrowserCallable
public class Tst {
    @NonNull
    public <T extends DTOBoundary> DTO<T> getDTO() {
        return new DTO<>();
    }

    public static class DTO<T extends DTOBoundary> {
        public T get() {
            return null;
        }
    }

    public static class DTOBoundary {}
}

I'm getting the following error:

ERROR(TypeScript)  Type 'DTO' is not generic.
> 5 | async function getDTO_1(init?: EndpointRequestInit_1): Promise<DTO_1<DTOBoundary_1 | undefined>> { return client_1.call("Tst", "getDTO", {}, init); }

The DTO entity is generated as following:

interface DTO {
}
export default DTO;

However, if I remove the boundary from the DTO class:

    public static class DTO<T> {
        public T get() {
            return null;
        }
    }

the issue resolves.

Expected-behavior

DTO is generated correctly with boundaries:

interface DTO<T extends DTOBoundary> {
}

Reproduction

  1. Get the new project from start.vaadin.com.
  2. Create an endpoint with the code:
    @BrowserCallable
    public class Tst {
        @NonNull
        public <T extends DTOBoundary> DTO<T> getDTO() {
            return new DTO<>();
        }
    
        public static class DTO<T extends DTOBoundary> {
            public T get() {
                return null;
            }
        }
    
        public static class DTOBoundary {}
    }
    
  3. Run the application

System Info

OS: Windows + WSL Version: 24.7.3

Lodin avatar May 08 '25 08:05 Lodin

It would be complex to support the boundary properly. We aren't sure that Jackson would be able to deserialise correctly.

Also, if this is something you need, please share your use case.

platosha avatar May 13 '25 11:05 platosha