I am trying to take some javascript and translate it into typescript in order to use it with a webpage that will utilize Aurelia. I am having some syntax issues with the below lines. If anyone can point me in the right direction on this would be most appreciated. Lines are below. Thanks in advance
--Jason
//trying to see if the browser supports HTML5 FileReader functionality
//VS currently says filereader does not exist on type 'Window'
if (window.filereader)
//VS says Property 'trigger' does not exist on type 'HTMLElement'
document.getElementById('fileBox').trigger('click');
//VS says Property 'click' does not exist on type 'Element'
document.querySelector('.fileCont span').click(function () {
this.remove();
});
// Property 'file' does not exist on type 'HTMLImageElement'
var img = document.createElement("img");
img.file = file;
For types that haven't yet made it into the standard definition file, you can extend the interface to include the additional properties :
interface Window {
filereader: any;
}
if (window.filereader) {
}
If you are using a library, for example jQuery, you can grab a ready-made definition for that .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.