I am trying to provide intellisense / code completion into a javascript editor using the Monaco editor. The code needs to be valid javascript, not typescript.
Given some
This is how we do it for magikcraft.io: drop this code straight into the left pane in the playground, then hit Run:
monaco.editor.create(document.getElementById("container"), {
value: "function hello() {\n\talert('Hello world!');\n}",
language: "typescript"
});
const fact = `declare namespace custom { export function onMyEvent(event: customClass): void;
export class customClass {
customProperty: string;
}`;
const factFilename = 'myCustomNamespace';
this.monaco.languages.typescript.typescriptDefaults.addExtraLib(fact, factFilename);
Now, in the right pane, then type: custom.
and you'll get autocomplete for the custom facts.