I'm declaring an interface which will contains image also. What type do i need to give to it.
export interface AdInterface {
email: string;
mobile: number;
image?: ??
}
If your image property contains ...
Image used as <img> element
image?: HTMLImageElement
URL to image.
image?: String
Image as file from <input> element
image?: File
array. If you need work with HTMLImageElement or File instead then you need to convert your byte array by conversion specific procedure depending on your needs. Conversions are usualy done by converting to base64 string. More details and examples are at stackoverflow.com/questions/20756042/… and stackoverflow.com/questions/35038884/…Most image when imported into server-side TypeScript are strings.
For example trying to reference File or HTMLImageElement on an imported image you will get this error:
TS2322: Type 'string' is not assignable to type 'HTMLImageElement'.
I recommend just using string. If you are having an import error for PNG images in TypeScript then take a look here.
<img>element?