summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Matt Kane <m@mk.gg> 2025-04-28 13:12:55 +0100
committerGravatar GitHub <noreply@github.com> 2025-04-28 13:12:55 +0100
commitb4929ae9e77f74bde251e81abc0a80e160de774a (patch)
tree74dba01c71b2b05f738e15ed2112f440f48716f3
parent60d5be4af49a72e3739f74424c3d5c423f98c133 (diff)
downloadastro-b4929ae9e77f74bde251e81abc0a80e160de774a.tar.gz
astro-b4929ae9e77f74bde251e81abc0a80e160de774a.tar.zst
astro-b4929ae9e77f74bde251e81abc0a80e160de774a.zip
fix: recursive content schema types (#13706)
-rw-r--r--.changeset/red-boxes-bet.md5
-rw-r--r--packages/astro/types/content.d.ts15
2 files changed, 16 insertions, 4 deletions
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<string, BaseAtomicSchema[]>
+ // 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>, ...z.any[]]>
+
type BaseSchemaWithoutEffects =
- | import('astro/zod').AnyZodObject
- | import('astro/zod').ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]>
- | import('astro/zod').ZodDiscriminatedUnion<string, import('astro/zod').AnyZodObject[]>
- | import('astro/zod').ZodIntersection<BaseSchemaWithoutEffects, BaseSchemaWithoutEffects>;
+ | BaseAtomicSchema
+ | BaseCompositeSchema
+ | import('astro/zod').ZodIntersection<BaseAtomicSchema, BaseAtomicSchema | BaseCompositeSchema>;
export type BaseSchema =
| BaseSchemaWithoutEffects