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

[Bug]: When using a custom component in MDX, VSCode reports an error #1412

Open
nick938 opened this issue Sep 12, 2024 · 2 comments
Open

[Bug]: When using a custom component in MDX, VSCode reports an error #1412

nick938 opened this issue Sep 12, 2024 · 2 comments
Labels
🐞 bug Something isn't working

Comments

@nick938
Copy link

nick938 commented Sep 12, 2024

版本信息

System:
    OS: Windows 11 10.0.22631
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i9-13900H
    Memory: 6.31 GB / 31.75 GB
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    rspress: ^1.29.0 => 1.30.0

问题详情

在vscode终端中运行pnpm create rspress@latest 后,修改/docs/guide/index.md 为/docs/guide/index.mdx.
然后导入组件
import { Badge } from "@theme";

vscode提示找不到模块“@theme”或其相应的类型声明 ![image](https://github.com/user-attachments/assets/e60d2cd2-a298-41d0-a30f-0678be1d85e7)

复现链接

pnpm create rspress@latest 修改md为mdx,导入rsprss内置组件

复现步骤

1.pnpm create rspress@latest
2.找个文件修改md为mdx,
3.导入rsprss内置组件

@nick938 nick938 added the 🐞 bug Something isn't working label Sep 12, 2024
@nick938
Copy link
Author

nick938 commented Sep 12, 2024

注释掉tsconfig.json中的
"mdx": {
"checkMdx": true
},不会出现报错

@Timeless0911
Copy link
Collaborator

@theme is an alias which is converting in rspress build process, thus allowing users to use theme component without installing the corresponding theme package.

'@theme': [CUSTOM_THEME_DIR, DEFAULT_THEME],

The default template set mdx.checkMdx true, so there is an error in vscode.

This can be ignored. Or you can mannually install @rspress/theme-default in your project and use like import { Badge } from "@rspress/theme-default".

@Timeless0911 Timeless0911 changed the title [Bug]: 在mdx中使用自定义组件时,vscode报错 [Bug]: When using a custom component in MDX, VSCode reports an error Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants