Skip to content

invalid-usage

Id
@azure-tools/typespec-client-generator-core/invalid-usage

Severity: error

This diagnostic is issued when the value passed to the @usage decorator is not one of the supported usage flags.

  • Area: SDK model usage overrides. Blocks unsupported explicit usage flags from being added to generated model, enum, or union metadata.
  • Not affected: Usage inferred from actual operation inputs and outputs is still calculated separately.
enum CustomUsage {
custom: 8,
}
@usage(CustomUsage.custom) // `8` is not a supported Usage flag
model Widget {}

TCGC reports:

Usage value must be one of: 2 (input), 4 (output), 256 (json), or 512 (xml).

Pass one or more of Usage.input, Usage.output, Usage.json, or Usage.xml to @usage, and remove custom or empty usage values:

@usage(Usage.input | Usage.json)
model Widget {}