Skip to content

Commit cb14568

Browse files
committed
Fix types
1 parent 4f54017 commit cb14568

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

index.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
/**
2-
* @typedef {import('mdast').Content|import('mdast').Root} MdastNode
2+
* @typedef {import('mdast').Content|import('mdast').Root} Node
33
*/
44

55
import {visit} from 'unist-util-visit'
66

77
/**
88
* Make an mdast tree compact by merging adjacent text nodes and block quotes.
99
*
10-
* @template {MdastNode} Tree
10+
* @template {Node} Tree
1111
* @param {Tree} tree
1212
* @returns {Tree}
1313
*/
1414
export function compact(tree) {
15-
visit(tree, (child, index, parent) => {
15+
// @ts-expect-error: hush, TS.
16+
visit(tree, visitor)
17+
18+
return tree
19+
20+
/**
21+
* @param {import('mdast').Content} child
22+
* @param {number} index
23+
* @param {Extract<Node, import('mdast').Parent>} parent
24+
*/
25+
function visitor(child, index, parent) {
1626
if (
1727
parent &&
1828
index &&
@@ -40,7 +50,5 @@ export function compact(tree) {
4050
return index
4151
}
4252
}
43-
})
44-
45-
return tree
53+
}
4654
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
5555
"test-api": "node test.js",
5656
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
57-
"test": "npm run format && npm run test-coverage"
57+
"test": "npm run build && npm run format && npm run test-coverage"
5858
},
5959
"prettier": {
6060
"tabWidth": 2,

0 commit comments

Comments
 (0)