Skip to content

Commit aa5933b

Browse files
authored
Refactor to use @import to import types
Closes GH-836. Reviewed-by: Titus Wormer <tituswormer@gmail.com>
1 parent 7f32314 commit aa5933b

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

lib/index.js

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
// Register `Raw` in tree:
2-
/// <reference types="mdast-util-to-hast" />
3-
41
/**
5-
* @typedef {import('hast').Element} Element
6-
* @typedef {import('hast').ElementContent} ElementContent
7-
* @typedef {import('hast').Nodes} Nodes
8-
* @typedef {import('hast').Parents} Parents
9-
* @typedef {import('hast').Root} Root
10-
* @typedef {import('hast-util-to-jsx-runtime').Components} JsxRuntimeComponents
11-
* @typedef {import('remark-rehype').Options} RemarkRehypeOptions
12-
* @typedef {import('unist-util-visit').BuildVisitor<Root>} Visitor
13-
* @typedef {import('unified').PluggableList} PluggableList
2+
* @import {Element, ElementContent, Nodes, Parents, Root} from 'hast'
3+
* @import {Components as JsxRuntimeComponents} from 'hast-util-to-jsx-runtime'
4+
* @import {Options as RemarkRehypeOptions} from 'remark-rehype'
5+
* @import {BuildVisitor} from 'unist-util-visit'
6+
* @import {PluggableList} from 'unified'
147
*/
158

169
/**
@@ -233,7 +226,7 @@ export function Markdown(options) {
233226
passNode: true
234227
})
235228

236-
/** @type {Visitor} */
229+
/** @type {BuildVisitor<Root>} */
237230
function transform(node, index, parent) {
238231
if (node.type === 'raw' && parent && typeof index === 'number') {
239232
if (skipHtml) {

test.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @jsxRuntime automatic @jsxImportSource react */
22
/**
3-
* @typedef {import('hast').Root} Root
4-
* @typedef {import('react-markdown').ExtraProps} ExtraProps
3+
* @import {Root} from 'hast'
4+
* @import {ExtraProps} from 'react-markdown'
55
*/
66

77
import assert from 'node:assert/strict'

0 commit comments

Comments
 (0)