"Intersection results could not be merged" does not mention the cause #3194
-
Zod is great and I'm enjoying the features around intersecting/merging objects. But for
Not sure if this is a bug report or feature request, but: could the error message also include which field(s) are problematic? Note that I'm not trying to report that the error is wrong. The error may be right - it just informative enough to explain why clearly. Sorry that I'm not familiar enough with Zod to provide a standalone reproduction (I tried the Stackblitz Astro starter but couldn't get past TypeScript errors, amusingly). But here's how to get it on a real world project:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
from what I can see the problem code is this: import { rssSchema } from "@astrojs/rss"
const rssSchemaStrict = rssSchema.and(
z.object( {
link: z
.string()
.transform( ( link ) =>
link.replace( /^src\/content/, "" ).replace( /index.mdx$/, "" ),
),
pubDate: z.date(),
title: z.string(),
} ),
) it seems that I suggest you use the schema from here instead: If you found my answer satisfactory, please consider supporting me. Even a small amount is greatly appreciated. Thanks friend! 🙏 |
Beta Was this translation helpful? Give feedback.
from what I can see the problem code is this:
it seems that
rssSchema
is of typeZodEffect
, so that means it has atransform
or something at the end of the schema which makes it not an object schema, which means it can't be used with.and()
I suggest you use the schema from here instead:
https://github.com/withastro/astro/blob/main/packages/astro-rss/src/schema.ts
…