dgs-codegen icon indicating copy to clipboard operation
dgs-codegen copied to clipboard

Default constructor could be visible when JSpecify is enabled with all nullable fields

Open sjohnr opened this issue 1 month ago • 0 comments

When JSpecify is enabled (generateJSpecifyAnnotations = true), object types with all nullable fields (no non-null fields) generates a private default no-arg constructor. It could be made conditionally public based on nullability of fields.

Context:

When generateJSpecifyAnnotations = true, the no-arg constructor is never visible. This is intended so applications begin using the public all-args constructor to benefit from nullability annotations or use builders instead. However, it does not currently check nullability on fields to decide when to hide the default no-arg constructor.

sjohnr avatar Dec 09 '25 18:12 sjohnr