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
- Open the file and verify
CloudinaryImageMetadata is declared as z.infer<typeof CloudinaryImageMetadataSchema>.
- Add a field to
CloudinaryImageMetadataSchema — expect CloudinaryImageMetadata to automatically include the new field.
- Run
tsc --noEmit — expect no type errors.
Done when
CloudinaryImageMetadata is inferred from CloudinaryImageMetadataSchema and no hand-written parallel type declaration exists.
Why
CloudinaryImageMetadatais declared as a hand-written type alias in parallel withCloudinaryImageMetadataSchema, requiring both declarations to be kept in sync manually — asatisfiesconstraint makes today's version consistent but cannot prevent future divergence.Current state
io/cloudinary/fetchCloudinaryImageMetadata.tslines 22–30 defineexport type CloudinaryImageMetadata = { alt: string; ... }as a hand-written type. Lines 39+ defineCloudinaryImageMetadataSchema … satisfies z.ZodType<CloudinaryImageMetadata>. Two declarations must always match; neither can be the single source of truth for the other.Ideal state
CloudinaryImageMetadatatype alias is removed.CloudinaryImageMetadatais declared astype CloudinaryImageMetadata = z.infer<typeof CloudinaryImageMetadataSchema>.satisfiesconstraint is needed.Starting points
io/cloudinary/fetchCloudinaryImageMetadata.ts— lines 22–30 (the hand-written type to remove) and line 39 (thesatisfiesconstraint to remove)QA plan
CloudinaryImageMetadatais declared asz.infer<typeof CloudinaryImageMetadataSchema>.CloudinaryImageMetadataSchema— expectCloudinaryImageMetadatato automatically include the new field.tsc --noEmit— expect no type errors.Done when
CloudinaryImageMetadatais inferred fromCloudinaryImageMetadataSchemaand no hand-written parallel type declaration exists.