Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

Access to typings of a remote javascript library in typescript

I have a Javascript library that I imported into my Angular10 application. I imported the library via a script in the index html like:

<script src="..."></script>

Then, I added a module ref to the typings.d.ts file like:

declare var libRef: any;

Then, in a component's typescript file, I use a resource (TileLayer in the example) defined in the library like:

new libRef.TileLayer(options);

However, I cannot see any other resources that can be accessed via libRef i.e. I do not have any type information. For instance, I cannot define a variable like:

const layer: TileLayer; or
const layer: libRef.TileLayer

I can only define a TileLayer with any.

How can I achieve this, e.g. I'd like to see the details of the TileLayer class (with ctrl+click) or I'd like to have autocompletion functionality for that library.

BTW, I'm using Intellij IDEA for development.

Thanks in advance.

question from:https://stackoverflow.com/questions/66060443/access-to-typings-of-a-remote-javascript-library-in-typescript

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...