Skip to content
New issue

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

fix(@astro/mdx): add components property to RenderResult type definition #12245

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'];
}>;
}
}
Loading