Closed as not planned
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Problem
Currently the type of the AST is any
in the Pluggable
and PluggableList
types. I think it would be nice if they can be specified explicitly, and default unist Node
.
For example, this is a nice to have
import { compile } from '@mdx-js/mdx'
compile('', {
remarkPlugins: [
() => (ast) => {
// ast is of type mdast.Root
}
],
rehypePlugins: [
() => (ast) => {
// ast is of type hast.Root
},
// This is a type error. It belongs in remarkPlugins
remarkFrontmatter
]
})
Solution
In https://github.com/unifiedjs/unified/blob/main/index.d.ts#L592-L606:
/**
* A union of the different ways to add plugins and settings.
*
* @typeParam PluginParameters
* Plugin settings.
*/
export type Pluggable<PluginParameters extends any[] = any[], Root = Node> =
| PluginTuple<PluginParameters, Root, Root>
| Plugin<PluginParameters, Root, Root>
| Preset
/**
* A list of plugins and presets.
*/
- export type PluggableList = Pluggable[]
+ export type PluggableList<Root = Node> = Pluggable<any[], Root>[]
Alternatives
Keep it as-is.
Activity