Ildelian
Ildelian

Reputation: 1318

Load a external typescript library definition

I'm using monaco editor on my project, and I have to load some typescript .d.ts models into the monaco intellisense programmatically.

I'm using "Add Extra lib" for this purpose:

monaco.languages.typescript.javascriptDefaults.addExtraLib("", libUrl);     

My problem is that, nothing happens. LibURL is a valid http url: http:///127.0.0.1:1880/myapp/models/load/index.d.ts

That returns the definition file, how i can load it into monaco intellisense? But I can't see the models on the intellisense

Kind regards.

Upvotes: 1

Views: 1653

Answers (2)

Ildelian
Ildelian

Reputation: 1318

I finally have found what is wrong.

Monaco can't load full ts files like this:

declare class MyClass {
       
}
export default MyClass;

The model file, can only have functions and classes, no imports or exports or another kind of sentences are allowed:

declare class MyClass {
       
}

Upvotes: 1

Mike Lischke
Mike Lischke

Reputation: 53522

What you think is a URL is in fact the content of a typings file. You have to download the file yourself and feed it as parameter to addExtraLib.

Upvotes: 1

Related Questions