Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
6.3.1, 6.4.0 Beta1
-
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
- Build and run the attached project. Notice that both Texts show "Hello World", as expected.
- 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 |
422323,5 | QmlCompiler: Recognize script types when looking up members | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
423430,4 | QmlCompiler: Recognize script types when looking up members | 6.4 | qt/qtdeclarative | Status: MERGED | +2 | 0 |