-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Markdown-it plugin type issue #3935
Comments
Fixed the issue here, but your plugin types are wrong too. They are for markdown-it v13. You need to change imports: import type { RenderRule } from 'markdown-it/lib/renderer.mjs';
...
const renderToken: RenderRule = ... upstream issue - Swatinem/rollup-plugin-dts#311 |
Sorry I'm not familiar with markdown-it, so you mean @types/markdown-it contains both types for v13 and v14 and I'm using the v13 part?🤣 |
No. That part is also throwing error in the stackblitz example you've provided. I'm just suggesting how to fix errors inside that plugins/externalLinkIcon.ts file PS: you don't need a plugin for external link icon, it's now builtin https://vitepress.dev/reference/default-theme-config#externallinkicon |
That's a bit confusing, because I installed the v14 of import type { Renderer } from 'markdown-it';
type RenderRule = Renderer.RenderRule; import type { RenderRule } from 'markdown-it/lib/renderer.mjs'; PS: yeah I'm aware there's a built-in one, but I just want to use my own icon there. |
And I believe I need to fix below as per your suggestion as well, even I don't understand why is that🤦♀️ import type { ParserBlock } from 'markdown-it';
type RuleBlock = ParserBlock.RuleBlock; To import type { RuleBlock } from 'markdown-it/lib/parser_block.mjs'; I believe import type { PluginSimple } from 'markdown-it'; |
no there is no
yeah You can just type and check. If it doesn't show errors like this, then it's okay:
|
Indeed it's confusing, wondering if there's a way I can default it to import from ESM dts file instead of CJS, without having to add |
Ah, sorry. I was getting those errors because I changed moduleResolution to nodenext in your example's tsconfig. Right, with moduleResolution node it will resolve to CJS export and it will not throw any error on
You can try setting your moduleResolution to bundler. |
Yes, I've tried it as it works both ways with the new fix.
Yeah that works. Thanks for the suggestion! |
Also thanks for the quick fix💖 Appreciate that. |
Describe the bug
I'm encountering the type issue of
markdown-it
when using themarkdown.config
property in the vitepress config file.I have 3 plugins, all with issues.
I reproduced the simplest one in the reproduction below. I believe they have the same problem.
I'll log all the issues I'm having in Additional Context field, but please have a look at the reproduction below, thanks.
Reproduction
https://stackblitz.com/edit/vite-qvbnhu?file=docs%2F.vitepress%2Fconfig.ts
Expected behavior
No error is raised.
System Info
Additional context
Validations
The text was updated successfully, but these errors were encountered: