Sur cette page

Avec

Cette catégorie d'avertissement est orthographiée « [with] » par qmllint.

Avec les instructions

Que s'est-il passé ?

L'instruction JavaScript « with » a été utilisée.

Pourquoi est-ce un problème ?

Les instructions « with » peuvent entraîner des faux positifs lors de l'analyse d'identificateurs non qualifiés. De plus, les instructions « with » sont considérées comme obsolètes par la dernière norme JavaScript.

Exemple

import QtQuick

Item {
    function f() {
        with (Math) {
            return PI
        }
    }
}

Pour corriger cet avertissement, remplacez l'instruction ` with ` par une propriété de déstructuration :

import QtQuick

Item {
    function f() {
        const { PI } = Math;
        return PI
    }
}

Remarque : vous trouverez d’autres suggestions de remplacement ici.

© 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.