pas2js async keyword IDE and compile errors

Issue #123 new
Scott Page created an issue

pas2js recently introduced a solution for using async/await, but none of the pas2js examples work in VSCode with OmniPascal.

pas2js examples and explanation of async/await use can be found here.

Aside and full disclosure, I'm using the new TMS WebCore VSCode extension, which in turn depends on OmniPascal. The use of the TMS extension shouldn't matter, but it's possible that they don't have all of their source code up-to-date with the latest pas2js version. Although this blog post seems to indicate that they do: TMS Software Delphi Components TMS WEB Core v1.6 beta brings the pas2js v2.0 quantum leap. My company is also in contact with Bruno from TMS on a regular basis, so maybe we need to start with him first.

When I add the async; keyword to the end of a procedure or function, I expect to see no errors, but instead see "'Begin' expected found ‘async'". When I compile, I get this error “Error: Directive "async" not allowed here”. So either way, I can’t use async/await.

Based on the pas2js documentation, I don't see any additional compiler directives that are required to make this work, and I also don't see any indication that the IDE needs to be informed of the existence of the async keyword.

Having to write JavaScript code in Delphi/Pascal is one thing, but also having to use it with Promises and not having ES6 async/await becomes a nightmare. It's already a pain in JavaScript, without async/await, so having that added without showing erroneous errors would be amazing.

Anyway, I hope I'm requesting this in the right place, and that it can be added soon, for everyone's sanity. Maybe I’m just not understanding how to implement this, and if so, some pointers would be appreciated.

Thanks!

Comments (0)

  1. Log in to comment