Is there a compiler conditional to silence the LSP

I am using TMSWebcore. The issues is that sometimes things compile because of the TMS transpiler, but the LSP objects to it. SO my code gets littered with red circles. And I find them annoying. It also masks real issues.

Is there an ifdef, just to silence the LSP?

2 Likes

The problem is that the TMS WEBCore adds in keywords which the IDE doesn’t understand. In particular it will moan about await which is used in WEBCore code a lot but currently has no equivalent in Delphi.

You can either turn off error insight (which is what I think you’re talking about) or wrap the error like so:

{$IFNDEF WIN32}await(SomeAsyncFunction(SomeParams));{$ENDIF}

This works because the IDE is parsing your project as a Windows 32-bit app - but the Pas2JS transpiler (which is what TMS WEBCore uses to do the work) will actually not set the WIN32 compiler DEF so the wrapped code will be compiled.

Funnily enough you don’t need to wrap your Async form methods because the IDE will simply ignore the attribute decoration:

procedure SomeButtonClick(Sender: TObject); // regular non async method
[async]procedure SomeAsyncFunction(Sender: TObject); // this will not generate an error
procedure AnotherButtonClick(Sender: TObject); // another regular non async method

and will not show an error.

You can also refer to the Pas2JS documentation to see what Delphi language features are or are not supported.

[I am a big fan of TMS WEBCore and I’ve personally used it in a substantial project]

Funnily enough I already did this about a year ago in some common units (between Windows server and WebApp) to simulate the set feature in TMS. But it had slipped my mind.

1 Like