From 1d4f6a4989bc1cfd7109b1bff41503f115660e02 Mon Sep 17 00:00:00 2001 From: Benjamin MENANT Date: Fri, 25 Oct 2024 12:17:23 +0200 Subject: [PATCH] fix(@astro/mdx): add components property to RenderResult type definition (#12245) --- .changeset/twenty-gifts-kick.md | 6 ++++++ packages/astro/client.d.ts | 1 + packages/astro/src/@types/astro.ts | 12 ++++++++---- .../mdx/template/content-module-types.d.ts | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .changeset/twenty-gifts-kick.md diff --git a/.changeset/twenty-gifts-kick.md b/.changeset/twenty-gifts-kick.md new file mode 100644 index 0000000000..e0ff890d65 --- /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 8e1d64f23d..185c190c77 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 19933ecb62..4c5a8b2b70 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 957f99895b..848289f01e 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']; }>; } }