TypeScript support for .mdx file extensions
See original GitHub issueSearch Terms
- .mdx
- mdx
- mdx support
Suggestion
Could or would it be on the road map to allow type checking in non .ts files. In my case i’m specifically wondering if TypeScript can type check React components in .mdx files
Use Cases
I’ve written a gatsby plugin gatsby-mdx-embed that allows users to embed media content from YouTube, Twitter, Instagram etc in their .mdx files.
The plugin is written in TypeScript and all of the components have props. It would be sweet if when these components are used in .mdx files a user could either see the prop types by hovering over the component or more importantly would get a type error (squiggly line) in their code editor if the prop name is incorrect or of incorrect type.
Examples
Here’s an example .mdx file
You can below there the Gist component accepts a gistLink
prop of type string.
<Playground>
<Gist gistLink="PaulieScanlon/ca0cc9239176066492cb2aba435edbf7" />
</Playground>
If a user misspelled gistLink
or provided a number / array or object etc the editor would alert them there’s been an error in the prop type used.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:163
- Comments:11 (3 by maintainers)
Top GitHub Comments
Similarly, when writing Storybook stories in MDX, it would be a big help to have TypeScript understand them. Stories are a kind of test, and not type-checking tests is a scary prospect.
I stumbled across this Issue while searching for type checking Storybook. And, while I haven’t tried it yet, I did see that @Yama-Tomo is working on this in https://github.com/Yama-Tomo/type-checking-MDX-in-storybook
Figured I would share it here incase anyone else is interested!