How to provide extra Code Info for monaco editor with a variable in global context

246 views Asked by At

I'm creating an application where a customer can edit scripts, which have a variable named "context" defined with two properties: "event" and "element".

The problem now, monaco editor does not know about this.

I now tried this code:

let monacoInfo = {
    content: `declare global {
        var context: { event: Event, element: Element };
    }`, filePath: 'global.d.ts'
}
monaco.languages.typescript.typescriptDefaults.setExtraLibs([monacoInfo]);

to supply the info to monaco, but it does not work. I also tried to remove the "declare global" with no success.

Any ideas? I would not register it on the window object, cause window.context will not work (cause the script is run with the variable locally defined)

0

There are 0 answers