explicit-types

July 2, 2025 ยท View on GitHub

Recommended Badge Category Badge Default Severity Badge warn

The {"extends": "solhint:recommended"} property in a configuration file enables this rule.

Description

Forbid or enforce explicit types (like uint256) that have an alias (like uint).

Options

This rule accepts an array of options:

IndexDescriptionDefault Value
0Rule severity. Must be one of "error", "warn", "off".warn
1Options need to be one of "explicit", "implicit"explicit

Example Config

{
  "rules": {
    "explicit-types": [
      "warn",
      "explicit"
    ]
  }
}

Notes

  • Solhint allows this rule to automatically fix the code with --fix option

Examples

๐Ÿ‘ Examples of correct code for this rule

If explicit is selected

uint256 public variableName

If implicit is selected

uint public variableName

If explicit is selected

uint256 public variableName = uint256(5)

๐Ÿ‘Ž Examples of incorrect code for this rule

If explicit is selected

uint public variableName

If implicit is selected

uint256 public variableName

At any setting

uint public variableName = uint256(5)

Version

This rule was introduced in Solhint 5.0.4

Resources