From 8f905594ee5e926d53639483a1f4cd67eb6f9cd8 Mon Sep 17 00:00:00 2001 From: Stefano Verna Date: Tue, 16 Jul 2024 10:51:29 +0200 Subject: [PATCH] Better typings --- src/components/Image/index.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/components/Image/index.ts b/src/components/Image/index.ts index f1f1d29..9d44694 100644 --- a/src/components/Image/index.ts +++ b/src/components/Image/index.ts @@ -17,29 +17,31 @@ import { } from '../NakedImage/utils'; import { Sizer } from './Sizer'; +type Maybe = T | null; + export type ResponsiveImageType = { - /** The aspect ratio (width/height) of the image */ - aspectRatio?: number; /** A base64-encoded thumbnail to offer during image loading */ - base64?: string; + base64?: Maybe; /** The height of the image */ - height?: number; + height?: Maybe; /** The width of the image */ width: number; + /** The aspect ratio (width/height) of the image */ + aspectRatio?: number; /** The HTML5 `sizes` attribute for the image */ - sizes?: string; + sizes?: Maybe; /** The fallback `src` attribute for the image */ - src?: string; + src?: Maybe; /** The HTML5 `srcSet` attribute for the image */ - srcSet?: string; + srcSet?: Maybe; /** The HTML5 `srcSet` attribute for the image in WebP format, for browsers that support the format */ - webpSrcSet?: string; + webpSrcSet?: Maybe; /** The background color for the image placeholder */ - bgColor?: string; + bgColor?: Maybe; /** Alternate text (`alt`) for the image */ - alt?: string; + alt?: Maybe; /** Title attribute (`title`) for the image */ - title?: string; + title?: Maybe; }; type State = {