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

Can't import QML module from .mjs module

XMLWordPrintable

      I have some JavaScript code in an .mjs module file that is called by C++. The C++ code also registers some types for QML to use:

          qmlRegisterUncreatableType<AiComponentData>("Isle", 1, 0, "AiComponentData", "AiComponentData should not be created in QML");
      

      I want to use those types in my .mjs file, just like I would in a .js file:

      .import Isle 1.0 as Isle
      
      export function foo() {
          print(AiComponentData.Friendly)
      }
      

      However, I get an error:

      error importing module: "Expected token `;'" "qrc:/script.mjs" "1"
      

      I need to import the module so that I can use the enum that's registered with the AiComponentData class.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qtqmlteam Qt Qml Team User
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes