I am using the library KonvasJs for React. (https://github.com/lavrton/react-konva#using-images)
To load an image in javascript/React it is
componentDidMount() {
const image = new window.Image();
image.src = "http://konvajs.github.io/assets/yoda.jpg";
image.onload = () => {
// setState will redraw layer
// because "image" property is changed
this.setState({
image: image
});
};
}
It works fine.
When I switch Typescript, I have this error:
I have tried also to add:
interface Window {
Image: typeof Image;
}
or
interface Windows extends Window {
Image: typeof Image;
}
or
declare global {
interface Window {
Image: typeof Image;
}
}
Without success
Related issues:
https://github.com/Microsoft/TypeScript/issues/10241