VSCode code completion for file based rules using RuleBuilder

Hello,

I try to use Visual Studio code to write file based rules based on openhab-js (JavaScript Scripting - Automation | openHAB).

I installed openhab-js to conf/automation/js.

The rules are working, but I have a usability issue:

When I write a rule with rules.JSRule({..., then I get nice code completion features from VSCode:
image

But when I try to use the rule builder, not even the when() method is known and there is no guidance from the IDE:
(second screenshot omitted because as a new user I can only provide one.)

Is this a missing feature of openhab-js or can I improve my configuration?

Cheers,
Christian.

second screenshot: no guidance for RuleBuilder
image

RuleBuilder is definitely available in openhab-js. You can find the code under rules/rule_builder.js.

The code completion built into VSCode here has nothing to do with openHAB. It’s standard JavaScript support.

Given that JavaScript is not strongly typed, I suspect that VSCode just can’t figure out the type of rules or because of the way when is defined and exposed as a part of rules. I’m not sure what can be done about that. In general I’ve found VSCode’s ability to do code completion with JavaScript to be limited in general.

OpenHab provides TypeScript type definitions (openhab-js/types at main · openhab/openhab-js · GitHub). This enables the IntelliSense feature in VSCode.

I just wondered whether I miss something in my setup or code for the rule builder.