Skip to content

Commit

Permalink
fix(@astro/mdx): add components property to RenderResult type definit…
Browse files Browse the repository at this point in the history
…ion (#12245)
  • Loading branch information
bmenant authored Oct 25, 2024
1 parent 9d6bcdb commit 1d4f6a4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/twenty-gifts-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@astrojs/mdx': patch
'astro': patch
---

Add `components` property to MDXInstance type definition (RenderResult and module import)
1 change: 1 addition & 0 deletions packages/astro/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ declare module '*.mdx' {
export const url: MDX['url'];
export const getHeadings: MDX['getHeadings'];
export const Content: MDX['Content'];
export const components: MDX['components'];

const load: MDX['default'];
export default load;
Expand Down
12 changes: 8 additions & 4 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2648,10 +2648,12 @@ export interface MarkdownInstance<T extends Record<string, any>> {

type MD = MarkdownInstance<Record<string, any>>;

export type MDXInstance<T extends Record<string, any>> = Omit<
export interface MDXInstance<T extends Record<string, any>> extends Omit<
MarkdownInstance<T>,
'rawContent' | 'compiledContent'
>;
> {
components: Record<string, AstroComponentFactory> | undefined;
}

export interface MarkdownLayoutProps<T extends Record<string, any>> {
frontmatter: {
Expand All @@ -2665,10 +2667,12 @@ export interface MarkdownLayoutProps<T extends Record<string, any>> {
compiledContent: MarkdownInstance<T>['compiledContent'];
}

export type MDXLayoutProps<T extends Record<string, any>> = Omit<
export interface MDXLayoutProps<T extends Record<string, any>> extends Omit<
MarkdownLayoutProps<T>,
'rawContent' | 'compiledContent'
>;
> {
components: MDXInstance<T>['components'];
}

export type GetHydrateCallback = () => Promise<() => void | Promise<void>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare module 'astro:content' {
Content: import('astro').MarkdownInstance<{}>['Content'];
headings: import('astro').MarkdownHeading[];
remarkPluginFrontmatter: Record<string, any>;
components: import('astro').MDXInstance<{}>['components'];
}>;
}
}

0 comments on commit 1d4f6a4

Please sign in to comment.