In questa pagina

Non utilizzare "void" nelle espressioni

Questa categoria di avviso viene indicata da qmllint con il nome " [void] ".

Non utilizzare espressioni void

Cosa è successo?

È stata utilizzata un'espressione void in JavaScript.

Perché è un problema?

L'espressione `void` è ormai per lo più superflua e può rendere poco chiara la logica di alcuni codici, sopprimendo i valori restituiti. È inoltre vietata in molti stili di codifica in quanto poco intuitiva e di difficile lettura.

Esempio

import QtQuick

Item {
    function undef() {
        return void 0
    }

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

Per risolvere questo avviso, rimuovere o sostituire l'uso di `void`:

import QtQuick

Item {
    function undef() {
        return undefined
    }

    function f() {
        somefunction()
    }
}

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.