Monaco Editor "System-wide" code-completition

In this Post (Add Custom Completition to javascript function node) I searched for a solution for a system-wide code-completition and the result was to wait for 2.0 and the integration of the monaco editor. Now I have installed it, but I don't now where I should write whatever?

What kind of code i have to write (jsdoc, as in the example in the previous post) or d.ts Files? And where should I write/put this code, that the monaco editor use it in every function node?

What in particular are you interested in adding - can you provide a small example?

Yes, let's use your example from the first post with jsdoc (maybe). (it could also be d.ts files, if its better).

I want to define some global variables/objects (like in the example). Rooms with devices, that have names and so on ... And I want to get "help" by the editor in every node to "find" my defined rooms, devices, properties ...

If I use it in the same node (like in your example) the code-completition works fine. If I add another function-node on the same flow, the code completition doesn't work. I think the editor doesn't "know" something about the jsdoc from the first node.

Where can I put the jsdoc (probably in settings.json? or somewhere else), so that the code-completition works in "every" node on "every" flow.

So, the issue is, each function is an isolated VM. What you declare in one function is not accessible from another.

For now, the easiest way to add definitions is to modify func.d.ts and add your interfaces e.g adding ...

interface MySubType {
    /** The name property of MySubType */
    name: string,
    /** The age property of MySubType */
    age?: number,
    /** The married property of MySubType */
    married?: boolean
}

 interface MyType {
    /** Just a number */
    id?: number,
    /** The subTypeRequired property description */
    subTypeRequired: MySubType,
    /** The subTypeOptional property description */
    subTypeOptional?: MySubType,
    /** The text property description */
    text?: string|boolean|number
}

you can use it in a function like this...

/** @type {MyType} */ let myType;

hzpRp0kNC3

Wow, that works fine. Probably it would be nice to enhance the monace-editor to search for an addtitional custom location "d.ts" file. But with this, I could already start.

Thank you very much for your help and the integration of the monaco - editor !!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.