Skip to content

Commit

Permalink
feat: Add Prettify utility for better type docs (#2)
Browse files Browse the repository at this point in the history
fix #1
  • Loading branch information
ivan-dalmet authored Jan 18, 2024
1 parent bec168d commit 2dc75af
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/typed-mdx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import matter from "gray-matter";

const CONTENT_FOLDER = "src/content";

type Prettify<T> = {
[K in keyof T]: T[K];
} & {};

function assertSchemaIsObject(
schema: z.Schema
): asserts schema is z.AnyZodObject {
Expand Down Expand Up @@ -131,10 +135,10 @@ export function defineCollection<Z extends z.Schema>(options: {
schema: Z;
strict?: boolean;
}): {
getAll: () => Promise<(z.infer<Z> & z.infer<typeof metadataSchema>)[]>;
getAll: () => Promise<(Prettify<z.infer<Z> & z.infer<typeof metadataSchema>>)[]>;
getBySlug: (
slug: string
) => Promise<z.infer<Z> & z.infer<typeof metadataSchema>>;
) => Promise<Prettify<z.infer<Z> & z.infer<typeof metadataSchema>>>;
schema: Z;
} {
assertSchemaIsObject(options.schema);
Expand Down

0 comments on commit 2dc75af

Please sign in to comment.