この警告カテゴリーはqmllintによって[with]

ステートメント

何が起こりましたか?

JavaScriptのwith

なぜ悪いのですか?

With文は修飾されていない識別子を分析するときに誤検出を引き起こす可能性があります。また、with 文は最新の JavaScript 標準では非推奨とされています。

import QtQuick

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

この警告を修正するには、with ステートメントを destructuring プロパティに置き換えてください:

import QtQuick

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

注: 置換のアイデアはこちらにもあります。

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