vojtechhabarta / typescript-generator

Generates TypeScript from Java - JSON declarations, REST service client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Record class generates empty typing

danielsuter opened this issue · comments

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
) {

}

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

Yes, I removed it and have the same behaviour.

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

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.

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.