Skip to content

no-generic-numeric

Id
@azure-tools/typespec-azure-core/no-generic-numeric

Don’t use generic types. Use more specific types instead.

Azure services should use numeric types that specify the bit-width instead of generic types.

  • Area: SDK, API

Generic numeric types lose precision or cannot be represented by a strong numeric type in language SDKs.

This rule corresponds to the LintDiff rule ValidFormats.

model Widget {
id: integer;
cost: float;
}
model Widget {
id: safeint;
cost: float32;
}

This includes extending generic numeric types.

model GenericInteger extends integer;
model Widget {
id: GenericInteger;
}
model Widget {
id: safeint;
}

Suppress only when required to match an existing API; otherwise use the defined numeric types for floating-point, fixed-point, or integer values.