Skip to content

astro-check (error): ImageFigure missing required width/height #567

Description

@lsr-explore

ImageFigure missing required width/height

Labels: bug, types
Estimated PR size: 1 file

Note

Ticket description was generated using Claude Code. Review before starting on a fix.

Note

The following issue adds support for npm run astro:check

Summary

src/components/ImageFigure.astro:23 passes src and alt to Astro's <Image> but no width or height. Astro's Image component requires explicit dimensions when the source is a remote string URL (only inferred for local imports).

astro check error

src/components/ImageFigure.astro:23:4 - error ts(2322): Type '{ src: string | ImageMetadata; alt: string; "class:list": (string | undefined)[]; }' is not assignable to type 'IntrinsicAttributes & Props'.
  Type '{ src: string | ImageMetadata; alt: string; "class:list": (string | undefined)[]; }' is not assignable to type 'IntrinsicAttributes & { [x: `data-${string}`]: any; title?: string | null | undefined; alt: string | null; about?: string | null | undefined; class?: string | null | undefined; ... 207 more ...; inferSize?: false | undefined; }'.
    Type '{ src: string | ImageMetadata; alt: string; "class:list": (string | undefined)[]; }' is missing the following properties from type '{ [x: `data-${string}`]: any; title?: string | null | undefined; alt: string | null; about?: string | null | undefined; class?: string | null | undefined; 'class:list'?: string | Record<string, boolean> | Record<...> | Iterable<...> | Iterable<...> | undefined; ... 206 more ...; inferSize?: false | undefined; }': width, height

23   <Image
      ~~~~~

Suggested fix

Decide what ImageFigure is meant to support:

  • If only local images (ImageMetadata): narrow the src prop type so <Image> can infer dimensions.
  • If remote images are intended: add width and height props (required) to ImageFigure's Props and forward them to <Image>.
  • If you want callers to optionally provide dimensions: use <img> directly instead of <Image> for the remote case.

Acceptance criteria

  • Error clears.
  • All current callers of ImageFigure still render correctly (grep for ImageFigure usages).
  • If dimensions are now required props, callers updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions