From 8ca946940cda0921c7c4c5fd57a721bdfe6fb339 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 24 Jun 2024 11:31:27 +0200 Subject: [PATCH] Refactor to use `@import`s --- packages/remark-parse/lib/index.js | 11 +++++------ packages/remark-stringify/lib/index.js | 11 +++++------ readme.md | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/remark-parse/lib/index.js b/packages/remark-parse/lib/index.js index 08f3b16b..567645c6 100644 --- a/packages/remark-parse/lib/index.js +++ b/packages/remark-parse/lib/index.js @@ -1,8 +1,7 @@ /** - * @typedef {import('mdast').Root} Root - * @typedef {import('mdast-util-from-markdown').Options} FromMarkdownOptions - * @typedef {import('unified').Parser} Parser - * @typedef {import('unified').Processor} Processor + * @import {Root} from 'mdast' + * @import {Options as FromMarkdownOptions} from 'mdast-util-from-markdown' + * @import {Parser, Processor} from 'unified' */ /** @@ -20,14 +19,14 @@ import {fromMarkdown} from 'mdast-util-from-markdown' * Nothing. */ export default function remarkParse(options) { - /** @type {Processor} */ + /** @type {Processor} */ // @ts-expect-error: TS in JSDoc generates wrong types if `this` is typed regularly. const self = this self.parser = parser /** - * @type {Parser} + * @type {Parser} */ function parser(document) { return fromMarkdown(document, { diff --git a/packages/remark-stringify/lib/index.js b/packages/remark-stringify/lib/index.js index d1a268af..7a751d6a 100644 --- a/packages/remark-stringify/lib/index.js +++ b/packages/remark-stringify/lib/index.js @@ -1,8 +1,7 @@ /** - * @typedef {import('mdast').Root} Root - * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownOptions - * @typedef {import('unified').Compiler} Compiler - * @typedef {import('unified').Processor} Processor + * @import {Root} from 'mdast' + * @import {Options as ToMarkdownOptions} from 'mdast-util-to-markdown' + * @import {Compiler, Processor} from 'unified' */ /** @@ -20,14 +19,14 @@ import {toMarkdown} from 'mdast-util-to-markdown' * Nothing. */ export default function remarkStringify(options) { - /** @type {Processor} */ + /** @type {Processor} */ // @ts-expect-error: TS in JSDoc generates wrong types if `this` is typed regularly. const self = this self.compiler = compiler /** - * @type {Compiler} + * @type {Compiler} */ function compiler(tree) { return toMarkdown(tree, { diff --git a/readme.md b/readme.md index 5243826b..3a32a7ea 100644 --- a/readme.md +++ b/readme.md @@ -413,8 +413,8 @@ For example: ```js /** - * @typedef {import('mdast').Root} Root - * @typedef {import('vfile').VFile} VFile + * @import {Root} from 'mdast' + * @import {VFile} from 'vfile' */ /**