Skip to content

Commit 2859260

Browse files
committed
Update unist-util-visit-parents
1 parent 404c563 commit 2859260

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
* @typedef {import('hast').Text} Text
66
* @typedef {import('hast').Parent} Parent
77
* @typedef {import('hast').Root} Root
8-
* @typedef {import('hast').Element['children'][number]} Content
9-
* @typedef {Parent['children'][number]|Root} Node
8+
* @typedef {import('hast').Element} Element
9+
* @typedef {import('hast').Content} Content
10+
* @typedef {Root|Content} Node
1011
*
1112
* @typedef {import('hast-util-is-element').Test} Test
1213
* @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult
@@ -76,10 +77,10 @@ export function findAndReplace(tree, find, replace, options) {
7677

7778
return tree
7879

79-
/** @type {import('unist-util-visit-parents').Visitor<Text>} */
80+
/** @type {import('unist-util-visit-parents/complex-types').BuildVisitor<Node, 'text'>} */
8081
function visitor(node, parents) {
8182
let index = -1
82-
/** @type {Parent|undefined} */
83+
/** @type {Root|Element|undefined} */
8384
let grandparent
8485

8586
while (++index < parents.length) {
@@ -88,15 +89,14 @@ export function findAndReplace(tree, find, replace, options) {
8889
if (
8990
ignored(
9091
parent,
91-
// @ts-expect-error hast vs. unist parent.
92+
// @ts-expect-error: TS doesn’t understand but it’s perfect.
9293
grandparent ? grandparent.children.indexOf(parent) : undefined,
9394
grandparent
9495
)
9596
) {
9697
return
9798
}
9899

99-
// @ts-expect-error hast vs. unist parent.
100100
grandparent = parent
101101
}
102102

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"dependencies": {
3535
"escape-string-regexp": "^5.0.0",
3636
"hast-util-is-element": "^2.0.0",
37-
"unist-util-visit-parents": "^4.0.0"
37+
"unist-util-visit-parents": "^5.0.0"
3838
},
3939
"devDependencies": {
4040
"@types/tape": "^4.0.0",

0 commit comments

Comments
 (0)