Skip to content Skip to sidebar Skip to footer

How To Use Use External Js In Typescript

I Generate the Angular JS code through the Typescript code. In one situation, I need to add external JS file to my typescript file and need to access the classes in the js file. I

Solution 1:

You need a .d.ts file (TypeScript definition file) for any non-TypeScript packages. The dependency references are only for TypeScript files (not plain js).

https://github.com/borisyankov/DefinitelyTyped

If a .d.ts file does not exist for your addin you can simply define an interface for it yourself (so that it thinks it exists).

It is purely for the strong-typing that it needs any definition, otherwise you can just cast your variable with <any> and call anything on it (whether it exists or not, just like normal JS) :)


Post a Comment for "How To Use Use External Js In Typescript"