monaco editor: use "d.ts"-file from npm install for intellisense

Viewed 510

I need intellisense of an d.ts-file which I installed via npm install mylibname.

The monaco-component provides an function addExtraLib like this example: Microsoft Monaco Example

What I don't understand is: All examples I found have to know the source-code to add it as the first parameter to addExtraLib(myKnownSourceCode)

But I just want to use the whole "d.ts"-file for intellisense.

Is this possible?

1 Answers

I think you misinterpret the source parameter. This is just an arbitrary string and I'm not even sure it's used for anything visible outside of monaco-editor.

Instead just call addExtraLib(typings, "myLibrary") or similar.

Side note: this is a global setting for the monaco editor, which means you cannot have different typings in different editors. This is sometimes not what you want and you can use setExtraLib instead. This is however only a partial solution. As soon as you have different editors on the same page/in the same window, which require different typings, this will not work well.

Related