Skip to content

Commit

Permalink
Refactor to use @import to import types
Browse files Browse the repository at this point in the history
Closes GH-836.

Reviewed-by: Titus Wormer <[email protected]>
  • Loading branch information
remcohaszing authored Jun 28, 2024
1 parent 7f32314 commit aa5933b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
19 changes: 6 additions & 13 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Register `Raw` in tree:
/// <reference types="mdast-util-to-hast" />

/**
* @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<Root>} 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'
*/

/**
Expand Down Expand Up @@ -233,7 +226,7 @@ export function Markdown(options) {
passNode: true
})

/** @type {Visitor} */
/** @type {BuildVisitor<Root>} */
function transform(node, index, parent) {
if (node.type === 'raw' && parent && typeof index === 'number') {
if (skipHtml) {
Expand Down
4 changes: 2 additions & 2 deletions test.jsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit aa5933b

Please sign in to comment.