Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update autocompletion for ECMAScript2021 #1421

Merged
merged 8 commits into from
Jun 24, 2022

Conversation

florian-h05
Copy link
Contributor

@ghys

Fixes #1358

This PR updates the openhab-js tern definitions for the breaking changes and improvements of the latest openhab-js release (2.0.0) as well as some other improvements.

The event properties are fixed.

The time and the things namespaces and the cloud notification actions are also added.

I have tested the change, everything works but I was unable to use the ItemConfig as parameter type for addItem and replaceItem.

Signed-off-by: Florian Hotze florianh_dev@icloud.com

This updates `addItem(...)` and `updateItem(...)` for the breaking
changes from openhab/openhab-js#109.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This adds the `things` namespace with the `Thing` class and the Thing
getter methods.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
…pt 2021+ openhab#1358

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 requested a review from a team as a code owner June 21, 2022 21:48
@relativeci
Copy link

relativeci bot commented Jun 21, 2022

Job #450: Bundle Size — 10.75MB (-0.17%).

33df501 vs 4622ff8

Changed metrics (3/10)
Metric Current Baseline
Initial JS 1.68MB(-0.09%) 1.68MB
Cache Invalidation 27.42% 63.9%
Modules 1511(-0.59%) 1520
Changed assets by type (1/7)
            Current     Baseline
JS 8.7MB (-0.21%) 8.72MB

View Job #450 report on app.relative-ci.com

@ghys
Copy link
Member

ghys commented Jun 22, 2022

Thanks!

I have tested the change, everything works but I was unable to use the ItemConfig as parameter type for addItem and replaceItem.

I tried with the obvious:

            "addItem": {
                "!doc": "Creates a new Item within openHAB (see JS Scripting docs/Standard Library/Items).",
                "!type": "fn(itemConfig: ItemConfig) -> Item",
                "!url": "https://openhab.org/addons/automation/jsscripting/#itemconfig"
            },

and it seems to work?

image

(however you shouldn't denote optional keys with '?' because they will be taken literally and added when you autocomplete).

"TimeNamespace": {
"toZDT": {
"!doc": "Converts nearly any representation of a time to a time.ZonedDateTime (see JS Scripting Docs/Standard Library/Time)",
"!type": "fn(time: any) -> time.ZonedDateTime"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that any is a TypeScript keyword, here is should be ?.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay thanks.
I will do this ASAP.

@florian-h05
Copy link
Contributor Author

I tried with the obvious:

and it seems to work?

Interesting, I was trying this yesterday evening and it did not work. I will recheck ASAP.

(however you shouldn't denote optional keys with '?' because they will be taken literally and added when you autocomplete).

Okay, I‘ll fix that.

@ghys
Copy link
Member

ghys commented Jun 22, 2022

Note that you do have to force the autocomplete with Ctrl-Space when inside the ItemConfig object's curly braces.

Another keyboard action that is... not properly documented is Ctrl-Q which will open a tooltip with the description of the term where the cursor is (also the docs links don't work, this is a bug).

image

Signed-off-by: Yannick Schaus <github@schaus.net>
Copy link
Member

@ghys ghys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@florian-h05 I addressed the points above in my last commit so that this PR is merged in time for 3.3.RC1. Thanks!

@ghys ghys merged commit d0df331 into openhab:main Jun 24, 2022
@ghys ghys added enhancement New feature or request main ui Main UI labels Jun 24, 2022
@ghys ghys added this to the 3.3 milestone Jun 24, 2022
@florian-h05
Copy link
Contributor Author

florian-h05 commented Jun 24, 2022

@ghys Thank you very much!

FYI: I was planning to address your comments this evening when I am back home, as I was not at home this week and did not have access to my machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autocomplete incorrect with ECMAScript 2021+
2 participants