Skip to content

meaninglessVoidOperators

Reports using the void operator on expressions that are already void or undefined.

✅ This rule is included in the ts logical presets.

The void operator is used to discard a return value and produce undefined. Applying void to a value that is already void or undefined is meaningless and indicates a likely mistake or unnecessary code.

This rule helps catch API changes where a function that previously returned a value no longer does, as well as ensuring that void is used consistently and intentionally.

void (() => {})();
function getValue() {}
void getValue();
const value: undefined = undefined;
void value;

This rule is not configurable.

If you intentionally use void for stylistic consistency regardless of the argument’s type, you may disable this rule.

For codebases that heavily rely on explicit void annotations for documentation purposes, this rule might produce unwanted warnings.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.