vojtechhabarta / typescript-generator

Generates TypeScript from Java - JSON declarations, REST service client
MIT License
1.14k stars 237 forks source link

Record class generates empty typing #1060

Closed danielsuter closed 4 months ago

danielsuter commented 4 months ago

I'm using JDK 17 and record classes. They're generated empty:

export interface ExaminationOverview { }

Configuration (build.gradle)

generateTypeScript {
    jsonLibrary = 'jackson2'
    classes = [
            'ch.xx.xx.repositories.examination.ExaminationOverview',
    ]
    // LocalDate will normally be serialized as string but later on used as date
    customTypeMappings = ['java.time.LocalDate:Date|string']
    sortDeclarations = true
    sortTypeDeclarations = true
    optionalProperties = 'useLibraryDefinition'
    outputFile = '../frontend/src/app/core/model/generated-types.ts'
    outputFileType = 'implementationFile'
    outputKind = 'module'
}

Java record

public record ExaminationOverview(
        long id,
        LocalDate date,
        long numberOfGroups,
        ExaminationState state
) {

}
panchenko commented 4 months ago

Have you tried to check if that's caused by the customTypeMappings definition? records per se are handled fine for me.

danielsuter commented 4 months ago

Yes, I removed it and have the same behaviour.

panchenko commented 4 months ago

As already mentioned - it works for me. If you can provide a complete example - that would help to understand the problem better.

danielsuter commented 4 months ago

I just tried to create a minimal example. The same record class suddenly works. I'll try to play around with the dependencies to see if something changes.

danielsuter commented 4 months ago

ok, I figured it out. It's a side effect from the Heroku plugin v. 2.0.0. If I remove it, it works. Sorry for the false alarm.