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
898 stars 56 forks source link

Nested parameterized types are lost in generation #864

Open cromoteca opened 1 year ago

cromoteca commented 1 year ago

Description of the bug

Looks like only simple parameterized types are generated as expected. Nested ones are lost.

Minimal reproducible example

I wrote this code:

public record LocalStorageConfiguration(String name, String path, int port) {}
public record ConnectedStorageConfiguration(String name, String path, EncryptionType encryptionType) {}
public Pair<List<LocalStorageConfiguration>, List<ConnectedStorageConfiguration>> listStorages() {
  ...
}

where Pair is this class (a simple generic pair of two objects).

Expected behavior

The two records are translated to TS and the full return type information is preserved on listStorages.

Actual behavior

The records are not generated in TS and I get this method in the endpoint:

async function listStorages_1(init?: EndpointRequestInit_1): Promise<Pair_1> {
  return client_1.call("ConfigurationEndpoint", "listStorages", {}, init);
}

Versions:

- Vaadin / Hilla version: 2.0.2
- Node version: v18.15.0
- Java version: openjdk version "17.0.6" 2023-01-17
- OS version: Fedora 37
- Browser version (if applicable):
- Application Server (if applicable):
- IDE/Editor (if applicable):
platosha commented 1 year ago

This is a known missing feature in Hilla about propagating generic types to TypeScript.

BTW another possible enhancement is to support Pair directly as tuples.

platosha commented 1 year ago

(once there is a Pair in Java that is.)