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

Not Support In typescript file #27

Closed
boswellgao opened this issue Apr 29, 2021 · 4 comments
Closed

Not Support In typescript file #27

boswellgao opened this issue Apr 29, 2021 · 4 comments

Comments

@boswellgao
Copy link

in index.tsx

import Readme from './Readme.mdx'

and the lint told me

Cannot find module './Readme.mdx' or its corresponding type declarations.ts(2307)
@silvenon
Copy link
Collaborator

Could you share more about your setup? Your Vite configuration, project structure, or ideally steps to reproduce the error.

@boswellgao
Copy link
Author

@silvenon Thank you for your reply

here you can get the project

https://github.com/boswellgao/vite-react-live-preview

@silvenon
Copy link
Collaborator

silvenon commented Apr 29, 2021

The problem is with TypeScript, not vite-plugin-mdx. Vite only compiles away TypeScript, it doesn't do any type checking. One way to solve your problem is to add a common type definition for all your *.mdx files by creating a file named e.g. src/mdx.d.ts (the name doesn't matter):

declare module '*.mdx' {
  let MDXComponent: (props: Record<string, unknown>) => JSX.Element
  export default MDXComponent
}

If you need to be more specific about a particular *.mdx, add a .d.ts file with the same name.

@boswellgao
Copy link
Author

@silvenon Thanks. you are right,it's typescript proplem
TypeScript support for .mdx file extensions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants