diff --git a/index.js b/index.js index ff903ce..174bffe 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ /** - * @typedef {import('hast-util-to-jsx-runtime').ExtraProps} ExtraProps * @typedef {import('./lib/index.js').AllowElement} AllowElement * @typedef {import('./lib/index.js').Components} Components + * @typedef {import('./lib/index.js').ExtraProps} ExtraProps * @typedef {import('./lib/index.js').Options} Options * @typedef {import('./lib/index.js').UrlTransform} UrlTransform */ diff --git a/lib/index.js b/lib/index.js index b97d6ed..d3d201f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,7 +1,6 @@ /** * @import {Element, ElementContent, Nodes, Parents, Root} from 'hast' - * @import {Components as JsxRuntimeComponents} from 'hast-util-to-jsx-runtime' - * @import {ReactElement} from 'react' + * @import {ComponentProps, ElementType, ReactElement} from 'react' * @import {Options as RemarkRehypeOptions} from 'remark-rehype' * @import {BuildVisitor} from 'unist-util-visit' * @import {PluggableList} from 'unified' @@ -21,7 +20,16 @@ */ /** - * @typedef {Partial<JsxRuntimeComponents>} Components + * @typedef ExtraProps + * Extra fields we pass. + * @property {Element | undefined} [node] + * passed when `passNode` is on. + */ + +/** + * @typedef {{ + * [Key in Extract<ElementType, string>]?: ElementType<ComponentProps<Key> & ExtraProps> + * }} Components * Map tag names to components. */ @@ -225,6 +233,9 @@ export function Markdown(options) { return toJsxRuntime(hastTree, { Fragment, + // @ts-expect-error + // React components are allowed to return numbers, + // but not according to the types in hast-util-to-jsx-runtime components, ignoreInvalidStyle: true, jsx,