Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to use @import to import types #836

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading