diff options
author | 2025-04-28 13:12:55 +0100 | |
---|---|---|
committer | 2025-04-28 13:12:55 +0100 | |
commit | b4929ae9e77f74bde251e81abc0a80e160de774a (patch) | |
tree | 74dba01c71b2b05f738e15ed2112f440f48716f3 | |
parent | 60d5be4af49a72e3739f74424c3d5c423f98c133 (diff) | |
download | astro-b4929ae9e77f74bde251e81abc0a80e160de774a.tar.gz astro-b4929ae9e77f74bde251e81abc0a80e160de774a.tar.zst astro-b4929ae9e77f74bde251e81abc0a80e160de774a.zip |
fix: recursive content schema types (#13706)
-rw-r--r-- | .changeset/red-boxes-bet.md | 5 | ||||
-rw-r--r-- | packages/astro/types/content.d.ts | 15 |
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 |