Skip to content

union-null

Id
@azure-tools/typespec-client-generator-core/union-null

Severity: warning

This diagnostic is issued when TCGC converts a union whose only possible value is null. A union with no non-null alternatives cannot produce a useful SDK type.

  • Area: SDK union type conversion. Generation continues with a fallback union shape, but a null-only union cannot become a useful SDK type.
  • Not affected: Other nullable unions with non-null variants are unaffected.

TCGC reports:

Cannot have a union containing only null types.

Add at least one non-null variant to the union or remove the union from the generated client surface.

This diagnostic should not be suppressed. Fix the spec so the union has at least one non-null variant, or remove the union from the generated client surface.