1

When I try to open html file wile running local server in browser, it works, but Qt complains about line in js where "await" is used. Below is a link to example that I'm trying to run.

https://github.com/tangl-services/tangl-dev/tree/main/tangl-demo-basic

I'm guessing that problem is using 'await' at top level of js file. But I import it with type attribute set to module:

<script type="module" src="http://localhost:8080/index.js"></script>

And that's how Qt output looks:

js: Uncaught SyntaxError: Unexpected reserved word
[13120:13124:1219/155759.050:INFO:CONSOLE(17)] "Uncaught SyntaxError: Unexpected reserved word", source: http://localhost:8080/index.js (17)

If await isn't available, is there an alternative solution?

crends
  • 65
  • 4
  • 1
    https://stackoverflow.com/questions/43832490/is-it-possible-to-use-await-without-async-in-js – epascarello Dec 19 '22 at 13:33
  • 1
    Not familiar with QWebEngineView, but it looks like it doesn’t support ECMAScript 2022, because that’s when [top-level `await`](//developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/await#top_level_await) has been introduced. – Sebastian Simon Dec 19 '22 at 13:35

1 Answers1

0

I tried to use some methods from different versions of ES and looks like at this moment Qt is still on ES11, when top-level await requires ECMAScript 2022 (Something like private fields from ES11 are available).

Thanks to Sebastian Simon for answer, leading me to that conclusion.

UPD: Installing newer version of Qt (6.4.1) fixed that problem.

crends
  • 65
  • 4