- Qt 6.11
- Qt Qml
- Qt Qml Tooling
- qmllint
- QML Lint Warning and Errors
- Do not use void in expressions
- Qt 6.11.2 Reference Documentation

Var used before declaration ◦ Warn about using assignment in conditions

# Do not use void in expressions

This warning category is spelled `[void]` by qmllint.

## Do not use void expressions

### What happened?

A JavaScript void expression was used.

### Why is this bad?

The void expression has become mostly redundant and can obscure the logic of some code by suppressing returned values. It is also prohibited in many code styles for being non-obvious and hard to read.

### Example

     import QtQuick

     Item {
         function undef() {
             return void 0
         }

         function f() {
             return void someFunction()
         }
     }

To fix this warning, remove or replace the use of void:

     import QtQuick

     Item {
         function undef() {
             return undefined
         }

         function f() {
             somefunction()
         }
     }

Var used before declaration ◦ Warn about using assignment in conditions