Gayan Ranasinghe Gayan Ranasinghe - 2 months ago 16
TypeScript Question

Typescript declaration for global function

I am trying to use image loading third party plugin blueimp. That plugin has global function

loadImage(
e.target.files[0],
function (img) {
document.body.appendChild(img);
},
{ maxWidth: 600 }
);


How can I call this function using typescript?

Answer

You can put the following line before the function call:

declare var loadImage;

[Playground]