Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.12.0 Alpha, 5.12
-
None
-
6146021eb72a0aca5cc635b577b5e43b60824bc8 (qt/qtdeclarative/5.12)
Description
app.mjs:
class Point { constructor(x = 0, y = 0) { this.x = x; this.y = y; } plus(other) { return new Point(this.x + other.x, this.y + other.y); } toString() { return `${this.constructor.name} { x: ${this.x}, y: ${this.y} }`; } } function main() { const p = new Point(1, 2); console.log('main()', p.plus(new Point(3, 4))); } export { main };
main.qml:
import QtQuick 2.12 import QtQuick.Window 2.3 import './app.mjs' as App Window { title: qsTr('ECMAScript 7 Test') width: 640 height: 480 Component.onCompleted: { App.main() // TypeError: Property 'main' of object TypeError: Type error is not a function } }
Removing class from app.mjs make this example work.
Moving class from app.mjs into separate module and importing it with import statement make this example work.
Renaming app.mjs into app.js and removing export keyword make this example work too.