hilla icon indicating copy to clipboard operation
hilla copied to clipboard

Don't generate identifiers starting with digits

Open tarekoraby opened this issue 2 years ago • 2 comments

Describe the bug

If a Hilla endpoint is passing or returning an object with a public getter/setter that starts with a digit, Hilla auto-generates TS types that start with digits as identifiers, leading to compilation error (as TS identifiers should not start with digits)a

Expected-behavior

Hilla wouldn't auto-generates TS types that have identifiers starting with a digit (perhaps, logging a warning when that happens).

Reproduction

Run a Hilla project with this endpoint:

@Endpoint
@AnonymousAllowed
public class HillaEndpoint {
    
    public Foo test() {
        return new Foo();
    }

    class Foo {
        public boolean is123asdf() {
            return true;
        }
    }
}

System Info

Hilla 2.4.0.beta1

tarekoraby avatar Nov 16 '23 07:11 tarekoraby

Throwing an exception in the Java parser could be a good first step.

platosha avatar Nov 16 '23 12:11 platosha

Not sure if an exception would work, sometimes users aren't able to modify the response type. In my experience it was from returning ResponseEntity that was writing out the models for the http status codes. (1xxInformational() for example).

qsevers23 avatar Nov 17 '23 01:11 qsevers23