From aa5933b98a196ce6c78b0676f4de42d679b0e285 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 28 Jun 2024 12:08:02 +0200 Subject: [PATCH] Refactor to use `@import` to import types Closes GH-836. Reviewed-by: Titus Wormer --- lib/index.js | 19 ++++++------------- test.jsx | 4 ++-- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/index.js b/lib/index.js index eb50216..a0f3e17 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,16 +1,9 @@ -// Register `Raw` in tree: -/// - /** - * @typedef {import('hast').Element} Element - * @typedef {import('hast').ElementContent} ElementContent - * @typedef {import('hast').Nodes} Nodes - * @typedef {import('hast').Parents} Parents - * @typedef {import('hast').Root} Root - * @typedef {import('hast-util-to-jsx-runtime').Components} JsxRuntimeComponents - * @typedef {import('remark-rehype').Options} RemarkRehypeOptions - * @typedef {import('unist-util-visit').BuildVisitor} Visitor - * @typedef {import('unified').PluggableList} PluggableList + * @import {Element, ElementContent, Nodes, Parents, Root} from 'hast' + * @import {Components as JsxRuntimeComponents} from 'hast-util-to-jsx-runtime' + * @import {Options as RemarkRehypeOptions} from 'remark-rehype' + * @import {BuildVisitor} from 'unist-util-visit' + * @import {PluggableList} from 'unified' */ /** @@ -233,7 +226,7 @@ export function Markdown(options) { passNode: true }) - /** @type {Visitor} */ + /** @type {BuildVisitor} */ function transform(node, index, parent) { if (node.type === 'raw' && parent && typeof index === 'number') { if (skipHtml) { diff --git a/test.jsx b/test.jsx index f803df9..91c0c78 100644 --- a/test.jsx +++ b/test.jsx @@ -1,7 +1,7 @@ /* @jsxRuntime automatic @jsxImportSource react */ /** - * @typedef {import('hast').Root} Root - * @typedef {import('react-markdown').ExtraProps} ExtraProps + * @import {Root} from 'hast' + * @import {ExtraProps} from 'react-markdown' */ import assert from 'node:assert/strict'