diff --git a/.changeset/twenty-gifts-kick.md b/.changeset/twenty-gifts-kick.md new file mode 100644 index 000000000000..e0ff890d6583 --- /dev/null +++ b/.changeset/twenty-gifts-kick.md @@ -0,0 +1,6 @@ +--- +'@astrojs/mdx': patch +'astro': patch +--- + +Add `components` property to MDXInstance type definition (RenderResult and module import) diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index 8e1d64f23dab..185c190c7729 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -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; diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 19933ecb6224..4c5a8b2b7062 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -2648,10 +2648,12 @@ export interface MarkdownInstance> { type MD = MarkdownInstance>; -export type MDXInstance> = Omit< +export interface MDXInstance> extends Omit< MarkdownInstance, 'rawContent' | 'compiledContent' ->; +> { + components: Record | undefined; +} export interface MarkdownLayoutProps> { frontmatter: { @@ -2665,10 +2667,12 @@ export interface MarkdownLayoutProps> { compiledContent: MarkdownInstance['compiledContent']; } -export type MDXLayoutProps> = Omit< +export interface MDXLayoutProps> extends Omit< MarkdownLayoutProps, 'rawContent' | 'compiledContent' ->; +> { + components: MDXInstance['components']; +} export type GetHydrateCallback = () => Promise<() => void | Promise>; diff --git a/packages/integrations/mdx/template/content-module-types.d.ts b/packages/integrations/mdx/template/content-module-types.d.ts index 957f99895baa..848289f01e58 100644 --- a/packages/integrations/mdx/template/content-module-types.d.ts +++ b/packages/integrations/mdx/template/content-module-types.d.ts @@ -4,6 +4,7 @@ declare module 'astro:content' { Content: import('astro').MarkdownInstance<{}>['Content']; headings: import('astro').MarkdownHeading[]; remarkPluginFrontmatter: Record; + components: import('astro').MDXInstance<{}>['components']; }>; } }