As a newbie to Typescript, I am diligently typing everything precisely as part of my learning journey.
A property called lqip
(low quality image placeholder) is being pulled from a CMS and should be a base64 encoded image. It's clearly a string, but it doesn't quite feel accurate to just type it as a string.
mainImage: Schema.Post["mainImage"] & {
// 🤔 can I be more precise? It should always be a base64 encoded image, not just any generic string…
// e.g. "data:image/jpeg;base64,/9j/2wBDAAYEB…"
lqip: string
}
Is there a specific data type for base64 encoded images in Typescript? My extensive Google searches only turned up information on atob
/btoa
conversions, rather than the type itself. Thank you!