From f413446a859e497395b3612e44d1540cc6b9dad7 Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Thu, 16 Mar 2023 22:35:14 +0100 Subject: [PATCH] Fix `image()` type to be compatible with ImageMetadata (#6568) * fix(assest): Fix `image()` type to be compatible with ImageMetadata * chore: changeset --- .changeset/perfect-humans-wink.md | 5 +++++ packages/astro/src/content/template/types.d.ts | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .changeset/perfect-humans-wink.md diff --git a/.changeset/perfect-humans-wink.md b/.changeset/perfect-humans-wink.md new file mode 100644 index 000000000000..7138b43ac940 --- /dev/null +++ b/.changeset/perfect-humans-wink.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix image() type to be compatible with ImageMetadata diff --git a/packages/astro/src/content/template/types.d.ts b/packages/astro/src/content/template/types.d.ts index 0651773dd204..2485e2699260 100644 --- a/packages/astro/src/content/template/types.d.ts +++ b/packages/astro/src/content/template/types.d.ts @@ -13,11 +13,22 @@ declare module 'astro:content' { export type CollectionEntry = (typeof entryMap)[C][keyof (typeof entryMap)[C]]; + // This needs to be in sync with ImageMetadata export const image: () => import('astro/zod').ZodObject<{ src: import('astro/zod').ZodString; width: import('astro/zod').ZodNumber; height: import('astro/zod').ZodNumber; - format: import('astro/zod').ZodString; + format: import('astro/zod').ZodUnion< + [ + import('astro/zod').ZodLiteral<'png'>, + import('astro/zod').ZodLiteral<'jpg'>, + import('astro/zod').ZodLiteral<'jpeg'>, + import('astro/zod').ZodLiteral<'tiff'>, + import('astro/zod').ZodLiteral<'webp'>, + import('astro/zod').ZodLiteral<'gif'>, + import('astro/zod').ZodLiteral<'svg'> + ] + >; }>; type BaseSchemaWithoutEffects =