Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-104701

qmllint does not resolve imported .js file inside QML module

    XMLWordPrintable

Details

    • c2805daaa5 (qt/qtdeclarative/dev) c2805daaa5 (qt/tqtc-qtdeclarative/dev) 5526bf7983 (qt/qtdeclarative/6.4) 5526bf7983 (qt/tqtc-qtdeclarative/6.4)

    Description

      This example project shows 2 different ways of importing and calling the same JS function. qmllint understands one of them but not the other.

       

      Relevant files

      // HelperLibrary.js
      .pragma library
      
      function foo() {
      	return "Hello World";
      }
      
      // main.qml
      import QtQuick
      import JsLibrary as JLib
      import "HelperLibrary.js" as HelperLib
      
      Window {
          width: 640
          height: 480
          visible: true
      	title: "qmllint JS Test"
      
      	Column {
      		Text { text: JLib.HelperLibrary.foo() }
      		Text { text: HelperLib.foo() }
      	}
      }
      
      // qmldir
      module JsLibrary
      typeinfo appJsLibrary.qmltypes
      prefer :/JsLibrary/
      HelperLibrary 1.0 HelperLibrary.js
      

       

      Steps to reproduce

      1. Build and run the attached project. Notice that both Texts show "Hello World", as expected.
      2. Navigate to the build folder and run `qmllint --qmldirs . JSLibrary\main.qml`

       

      Outcome

      qmllint is happy with HelperLib.foo() but doesn't understand JLib.HelperLibrary.foo()

      Warning: main.qml:12:35: Property "foo" not found on type "HelperLibrary"
      		Text { text: JLib.HelperLibrary.foo() }
      
                                      		^^^
      

      Attachments

        For Gerrit Dashboard: QTBUG-104701
        # Subject Branch Project Status CR V

        Activity

          People

            ulherman Ulf Hermann
            skoh-qt Sze Howe Koh
            Votes:
            6 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes