I got error for const image = new Image(); like this
'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.
and
Expected 1 arguments, but got 0.
How to solve error like that?
const onPreview = async (file: UploadFile) => {
let src = file.url as string;
if (!src) {
src = await new Promise((resolve) => {
const reader = new FileReader();
reader.readAsDataURL(file.originFileObj as RcFile);
reader.onload = () => resolve(reader.result as string);
});
}
const image = new Image();
image.src = src;
const imgWindow = window.open(src);
imgWindow?.document.write(image.outerHTML);
};
Assuming your trying to use HTMLImageElement: Image() constructor
And not a external package.
Try installing @types/node
,
npm install --save @types/node
// or
yarn add -D @types/node
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With