Skip to content

invalid-deserializeEmptyStringAsNull-target-type

Id
@azure-tools/typespec-client-generator-core/invalid-deserializeEmptyStringAsNull-target-type

Severity: error

This diagnostic is issued when @deserializeEmptyStringAsNull is applied to a property whose type is not string and is not a scalar derived from string.

  • Area: SDK deserialization customization. Blocks empty-string-to-null handling on non-string-like properties.
  • Not affected: Other properties and the service payload schema are unchanged.
model Widget {
@deserializeEmptyStringAsNull
count: int32; // property type is not `string` or string-derived
}

TCGC reports:

@deserializeEmptyStringAsNull can only be applied to `ModelProperty` of type 'string' or a `Scalar` derived from 'string'.

Apply the decorator only to a string property or a property whose scalar type ultimately extends string.

model Widget {
@deserializeEmptyStringAsNull
name: string;
}