Skip to content

Derive CloudinaryImageMetadata from CloudinaryImageMetadataSchema to eliminate dual-declaration #91

@ooloth

Description

@ooloth

Why

CloudinaryImageMetadata is declared as a hand-written type alias in parallel with CloudinaryImageMetadataSchema, requiring both declarations to be kept in sync manually — a satisfies constraint makes today's version consistent but cannot prevent future divergence.

Current state

io/cloudinary/fetchCloudinaryImageMetadata.ts lines 22–30 define export type CloudinaryImageMetadata = { alt: string; ... } as a hand-written type. Lines 39+ define CloudinaryImageMetadataSchema … satisfies z.ZodType<CloudinaryImageMetadata>. Two declarations must always match; neither can be the single source of truth for the other.

Ideal state

  • The hand-written CloudinaryImageMetadata type alias is removed.
  • CloudinaryImageMetadata is declared as type CloudinaryImageMetadata = z.infer<typeof CloudinaryImageMetadataSchema>.
  • Schema and type are always in sync by construction; no satisfies constraint is needed.

Starting points

  • io/cloudinary/fetchCloudinaryImageMetadata.ts — lines 22–30 (the hand-written type to remove) and line 39 (the satisfies constraint to remove)

QA plan

  1. Open the file and verify CloudinaryImageMetadata is declared as z.infer<typeof CloudinaryImageMetadataSchema>.
  2. Add a field to CloudinaryImageMetadataSchema — expect CloudinaryImageMetadata to automatically include the new field.
  3. Run tsc --noEmit — expect no type errors.

Done when

CloudinaryImageMetadata is inferred from CloudinaryImageMetadataSchema and no hand-written parallel type declaration exists.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions