vuepress
vuepress copied to clipboard
MarkDown.plugins type problem when configuring config.ts
- [x] I confirm that this is an issue rather than a question.
Bug report
I use vuepress v1.9.7
I use config.ts to configure VuePress, but I have encountered problems when configuring MarkDown.
Steps to reproduce
Description according to https://Vuepress.Vuejs.org/config/#markdown-plugins
What is expected?
I can use the following two ways at the same time.
import { MarkdownConfig } from "vuepress/config";
export default <MarkdownConfig>{
plugins: [
["markdown-it-sub", {}],
],
};
or
import { MarkdownConfig } from "vuepress/config";
export default <MarkdownConfig>{
plugins: {
"markdown-it-sub": {}
},
};
What is actually happening?
But the second (object style) type check cannot pass
Other relevant information
I found that the MarkdownConfig type in vuepress/types/src/markdon.ts has the following sections
plugins?: Array<string | [string, Record<string, any>]>;
It seems that there is no support for object type here.
I am temporarily solved with the following solutions.
import { MarkdownConfig } from "vuepress/config";
interface MyMarkdownConfig extends Omit<MarkdownConfig, "plugins"> {
plugins?: Record<string, any> | Array<string | [string, Record<string, any>]>;
}
export default <MyMarkdownConfig>{
plugins: {
"markdown-it-sub": {}
},
};