keystatic icon indicating copy to clipboard operation
keystatic copied to clipboard

Incompatible types between CloudImageProps and actual component props

Open JedWatson opened this issue 2 years ago • 0 comments

I was testing our new CloudImageProps type and it turns out it's incompatible with the types the component block actually provides 🤦

Type '({ src, alt, height, width }: CloudImageProps) => Element' is not assignable to type 'Comp<{ readonly src: string; readonly alt: string; readonly height: number | null; readonly width: number | null; }>'.
  Types of parameters '__0' and 'props' are incompatible.
    Type '{ readonly src: string; readonly alt: string; readonly height: number | null; readonly width: number | null; }' is not assignable to type 'CloudImageProps'.
      Types of property 'width' are incompatible.
        Type 'number | null' is not assignable to type 'number | undefined'.
          Type 'null' is not assignable to type 'number | undefined'.

When I define this type locally in the project, it's fine:

type CloudImageProps = {
  src: string;
  alt: string;
  height: number;
  width: number;
};

We should update the type we're exporting to allow for the null / undefined clash, so people don't have to type this locally.

JedWatson avatar Aug 28 '23 10:08 JedWatson