MDX and typescript? #1562
-
Is there a way to get type safety in an MDX file? export function Component(props : {src: string}) {
//...
} import { Component } from './component';
# Hello world
There should be some sort of build/IDE error here since it's missing the src property:
<Component/> |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
There is inside typescript files. As for type checking inside MDX files themselves, mdx-js/mdx-analyzer#165 and https://github.com/mdx-js/eslint-mdx are where this could live, but it has not been built out yet. |
Beta Was this translation helpful? Give feedback.
-
Hello is there a 2024 update? |
Beta Was this translation helpful? Give feedback.
There is inside typescript files.
For version 1 see https://github.com/mdx-js/mdx/blob/v1.6.22/docs/advanced/typescript.mdx
For version 2 https://github.com/mdx-js/mdx/blob/v2.0.0-next.9/docs/advanced/typescript.mdx
As for type checking inside MDX files themselves, mdx-js/mdx-analyzer#165 and https://github.com/mdx-js/eslint-mdx are where this could live, but it has not been built out yet.
Contributions adding support or financial support to help move the effort forward are welcome!