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

Can't import QML module from .mjs module

    XMLWordPrintable

    Details

      Description

      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.

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              qt.team.quick.subscriptions Qt Quick and Widgets Team
              Reporter:
              mitch_curtis Mitch Curtis
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes