vojtechhabarta/typescript-generator

@Nullable annotation not working as expected

Closed this issue · 2 comments

Hi - new to this library so I may have made a mistake. However, with this configuration:

    <configuration>
        <jsonLibrary>jackson2</jsonLibrary>
        <classPatterns>com.malcolmcrum.dto.**</classPatterns>
        <outputKind>global</outputKind>
        <optionalAnnotations>
          <optionalAnnotation>org.jetbrains.annotations.Nullable</optionalAnnotation>
        </optionalAnnotations>
    </configuration>

And this DTO:

package com.malcolmcrum.dto;
import org.jetbrains.annotations.Nullable;
class Test {
  @Nullable public String foo;
}

I get this output:

interface Test {
    foo: string;
}

But I expected foo?: string. What am I doing wrong?

A full demonstration is here: https://glitch.com/edit/#!/parallel-feline-tax?path=pom.xml%3A66%3A0

One issue is that the retention policy of jetbrain's annotation is CLASS and not RUNTIME - I think it's required for it in order to work. Do you still have the issue after using another lib?

That works! Demo here with the checker framework: https://glitch.com/edit/#!/tide-pond-crop?path=pom.xml%3A71%3A81