From da97ef35757f67a14ff0c0210839b0336bbe9317 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 28 Jun 2024 10:37:00 +0200 Subject: [PATCH 1/2] Use @import jsdoc comments to import types `@import` tags were introduced in TypeScript 5.5. --- lib/index.js | 16 ++++++---------- test.jsx | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/index.js b/lib/index.js index eb50216..23326e2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,15 +2,11 @@ /// /** - * @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 +229,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' From a09418a75cf5b7ff86b9cea38b91973eebbc1937 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 28 Jun 2024 11:57:10 +0200 Subject: [PATCH 2/2] Remove mdast-util-to-hast triple slash reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s redundant. --- lib/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 23326e2..a0f3e17 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,3 @@ -// Register `Raw` in tree: -/// - /** * @import {Element, ElementContent, Nodes, Parents, Root} from 'hast' * @import {Components as JsxRuntimeComponents} from 'hast-util-to-jsx-runtime'