TypeScript Version: atom-typescript
Code
new Image(); //works
new window.Image(); //ERROR: Property 'Image' des not exists on type 'Window'
Expected behavior:
Image constructor should exists in window object
Actual behavior:
Image constructor does not exists in window object
Other Info:
I actually ussing nw.js so I can't access to the window object directly:
function newImage( win: Window): Image {
return new win.Image(); //ERROR: Property 'Image' des not exists on type 'Window'
}
If I cast win as any, it works, but I loose the Typescript typing feature.
The library does not redefine all globals on window. if you want to use one of these on window you can add it, in one of your files add:
interface Window {
Image: typeof Image;
}
Thanks @mhegazy. But where do you add this snippet?

this works for me:
const image = new (window as any).Image()
image.src = './dragFile.png'
image.onload = () => {
this.setState({
image: image
})
}
source: https://stackoverflow.com/questions/50717127/new-window-image-is-not-working-with-typescript-react
interface Window {
Image: typeof Image,
}
declare const window: Window;
Declare it after defining it and it should work fine.