-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(mdx): add TypeScript types for Content components prop #14591
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
base: main
Are you sure you want to change the base?
feat(mdx): add TypeScript types for Content components prop #14591
Conversation
Adds proper TypeScript support for passing custom components to MDX Content component via the components prop. Changes: - Add MDXContentProps interface defining the components prop - Add MDXContent type that extends AstroComponentFactory with typed props - Update MDX render type to use MDXContent instead of plain function - Maintains link to base AstroComponentFactory type via intersection This addresses part of issue #14490 by providing TypeScript intellisense and type checking for the components prop when using await render(). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
🦋 Changeset detectedLatest commit: e728491 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Adds changeset documenting the new TypeScript support for the components prop on MDX Content component. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
CodSpeed Performance ReportMerging #14591 will not alter performanceComparing Summary
Footnotes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting for docs!
* <Content components={{ h1: MyCustomH1, img: MyImage }} /> | ||
* ``` | ||
*/ | ||
export interface MDXContentProps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling @ArmandPhilippot -- I don't think we document Markdown or MDX types, really. So, nothing to update, but is this something we should have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's useful to document these types like we do the ones where we expect users to import them into their project. They seem more useful internally than in a user project. And I don't recall seeing users complain those types are not documented/would have been useful.
We document MarkdownInstance
in plain text in Importing Markdown (without the type name). Well, I guess we could move/repeat this in the Import statements reference. And, we will document components
for MDX.
So, I think it's fine as it is!
Co-authored-by: Sarah Rainsberger <[email protected]>
Co-authored-by: Sarah Rainsberger <[email protected]>
Changes
<Content />
when usingawait render()
is undocumented, lacks type support, and differs from MDXProvider #14490Testing
N/A, type only
Docs