Skip to content

Commit b4929ae

Browse files
authored
fix: recursive content schema types (#13706)
1 parent 60d5be4 commit b4929ae

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.changeset/red-boxes-bet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes typechecking for content config schema

packages/astro/types/content.d.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@ declare module 'astro:content' {
4545
has: (key: string) => boolean;
4646
}
4747

48+
type BaseAtomicSchema = import('astro/zod').AnyZodObject;
49+
50+
type BaseCompositeSchema =
51+
| import('astro/zod').ZodUnion<[BaseAtomicSchema, ...BaseAtomicSchema[]]>
52+
| import('astro/zod').ZodDiscriminatedUnion<string, BaseAtomicSchema[]>
53+
// If we have a union of unions, give up on trying to type-check it all. You're on your own.
54+
| import('astro/zod').ZodUnion<[import('astro/zod').ZodUnion<z.any>, ...z.any[]]>
55+
4856
type BaseSchemaWithoutEffects =
49-
| import('astro/zod').AnyZodObject
50-
| import('astro/zod').ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]>
51-
| import('astro/zod').ZodDiscriminatedUnion<string, import('astro/zod').AnyZodObject[]>
52-
| import('astro/zod').ZodIntersection<BaseSchemaWithoutEffects, BaseSchemaWithoutEffects>;
57+
| BaseAtomicSchema
58+
| BaseCompositeSchema
59+
| import('astro/zod').ZodIntersection<BaseAtomicSchema, BaseAtomicSchema | BaseCompositeSchema>;
5360

5461
export type BaseSchema =
5562
| BaseSchemaWithoutEffects

0 commit comments

Comments
 (0)