We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Following the quickstart for mdx here https://www.content-collections.dev/docs/content/mdx
results in this:
But if i workaround it with a asserted type predicate then it's satisfied.
Did I miss something?
const me = defineCollection({ name: 'me', directory: 'content/data/me', include: '**/*.mdx', schema: (z) => ({ title: z.string(), description: z.string().optional(), }), transform: async (document, context) => { assert(isDocumentWithContent(document), 'Document has no content'); const mdx = await compileMDX(context, document); return { ...document, mdx, }; }, }); /** * Hack Predicate to override aggressive generics * done by content-collections/core */ function isDocumentWithContent<T extends { content: string }>( document: any ): document is T { return typeof document?.content === 'string'; } function assert(condition: any, message: string): asserts condition { if (!condition) { throw new Error(message); } }
I still get the error if I describe a content: z.string() in the schema:
content: z.string()
I imagine something is going awry here :
type AddContent< TShape extends ZodRawShape > = TShape extends { content: ZodTypeAny; } ? TShape : TShape & WithContent; type GetParsedShape< TParser extends Parser, TShape extends ZodRawShape > = Parsers[TParser]["hasContent"] extends true ? AddContent<TShape> : TShape; type GetShape< TParser extends Parser | undefined, TShape extends ZodRawShape > = TParser extends Parser ? GetParsedShape<TParser, TShape> : AddContent<TShape>; type Schema< TParser extends Parser | undefined, TShape extends ZodRawShape > = z$1.infer<ZodObject<GetShape<TParser, TShape>>> & { _meta: Meta; };
The text was updated successfully, but these errors were encountered:
I am currently on vacation. I'll take a look at it next week.
Sorry, something went wrong.
All good, no one expects you to deal with these issues straight away 👍🏻 (or even ever).
We have a workaround for now, so not a high priority
@airtonix i can't reproduce it. Which version of typescript do you use? And can you post your tsconfig?
No branches or pull requests
Following the quickstart for mdx here https://www.content-collections.dev/docs/content/mdx
results in this:
But if i workaround it with a asserted type predicate then it's satisfied.
Did I miss something?
I still get the error if I describe a
content: z.string()
in the schema:I imagine something is going awry here :
The text was updated successfully, but these errors were encountered: