From b4929ae9e77f74bde251e81abc0a80e160de774a Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Mon, 28 Apr 2025 13:12:55 +0100 Subject: fix: recursive content schema types (#13706) --- .changeset/red-boxes-bet.md | 5 +++++ packages/astro/types/content.d.ts | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .changeset/red-boxes-bet.md diff --git a/.changeset/red-boxes-bet.md b/.changeset/red-boxes-bet.md new file mode 100644 index 000000000..18642ea97 --- /dev/null +++ b/.changeset/red-boxes-bet.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes typechecking for content config schema diff --git a/packages/astro/types/content.d.ts b/packages/astro/types/content.d.ts index c40d867a4..5c9101549 100644 --- a/packages/astro/types/content.d.ts +++ b/packages/astro/types/content.d.ts @@ -45,11 +45,18 @@ declare module 'astro:content' { has: (key: string) => boolean; } + type BaseAtomicSchema = import('astro/zod').AnyZodObject; + + type BaseCompositeSchema = + | import('astro/zod').ZodUnion<[BaseAtomicSchema, ...BaseAtomicSchema[]]> + | import('astro/zod').ZodDiscriminatedUnion + // If we have a union of unions, give up on trying to type-check it all. You're on your own. + | import('astro/zod').ZodUnion<[import('astro/zod').ZodUnion, ...z.any[]]> + type BaseSchemaWithoutEffects = - | import('astro/zod').AnyZodObject - | import('astro/zod').ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]> - | import('astro/zod').ZodDiscriminatedUnion - | import('astro/zod').ZodIntersection; + | BaseAtomicSchema + | BaseCompositeSchema + | import('astro/zod').ZodIntersection; export type BaseSchema = | BaseSchemaWithoutEffects -- cgit v1.2.3