1
1
/**
2
2
* @typedef {import('unist-util-assert').AssertionError } AssertionError
3
3
*
4
- * @typedef {import('unist').Node } UnistNode
5
4
* @typedef {import('unist').Parent } UnistParent
6
- * @typedef {import('unist').Literal } UnistLiteral
7
5
*
8
6
* @typedef {import('mdast').Root } Root
9
- * @typedef {import('mdast').Content } Content
7
+ * @typedef {import('mdast').Nodes } Nodes
8
+ * @typedef {import('mdast').Parents } Parents
9
+ * @typedef {import('mdast').Literals } Literals
10
10
* @typedef {import('mdast').List } List
11
11
* @typedef {import('mdast').ListItem } ListItem
12
12
* @typedef {import('mdast').Heading } Heading
21
21
* @typedef {import('mdast').Table } Table
22
22
*/
23
23
24
- /**
25
- * @typedef {Root | Content } Node
26
- * @typedef {Extract<Node, UnistParent> } Parent
27
- * @typedef {Extract<Node, UnistLiteral> } Literal
28
- */
29
24
import nodeAssert from 'node:assert'
30
25
import { zwitch } from 'zwitch'
31
26
import { mapz } from 'mapz'
@@ -48,7 +43,7 @@ import {
48
43
* Thing to assert.
49
44
* @param {UnistParent | null | undefined } [parent]
50
45
* Optional, valid parent.
51
- * @returns {asserts tree is Node }
46
+ * @returns {asserts tree is Nodes }
52
47
* Nothing.
53
48
* @throws {AssertionError }
54
49
* When `tree` (or its descendants) is not an mdast node.
@@ -68,7 +63,7 @@ export function assert(tree, parent) {
68
63
* Thing to assert.
69
64
* @param {UnistParent | null | undefined } [parent]
70
65
* Optional, valid parent.
71
- * @returns {asserts tree is Parent }
66
+ * @returns {asserts tree is Parents }
72
67
* Nothing.
73
68
* @throws {AssertionError }
74
69
* When `tree` is not a parent or its descendants are not nodes.
@@ -86,7 +81,7 @@ export function parent(tree, parent) {
86
81
* Thing to assert.
87
82
* @param {UnistParent | null | undefined } [parent]
88
83
* Optional, valid parent.
89
- * @returns {asserts node is Literal }
84
+ * @returns {asserts node is Literals }
90
85
* Nothing.
91
86
* @throws {AssertionError }
92
87
* When `node` is not an mdast literal.
@@ -142,7 +137,7 @@ const all = mapz(mdast, {key: 'children'})
142
137
* Thing to assert.
143
138
* @param {UnistParent | null | undefined } [parent]
144
139
* Optional, valid parent.
145
- * @returns {asserts node is UnistNode }
140
+ * @returns {asserts node is Nodes }
146
141
* Nothing.
147
142
* @throws {AssertionError }
148
143
* When `node` is not a unist node.
@@ -160,7 +155,7 @@ function unknown(node, parent) {
160
155
*
161
156
* @param {unknown } [tree]
162
157
* Thing to assert.
163
- * @returns {asserts tree is Parent }
158
+ * @returns {asserts tree is Parents }
164
159
* Nothing.
165
160
* @throws {AssertionError }
166
161
* When `tree` is not a parent or its descendants are not nodes.
@@ -177,7 +172,7 @@ function assertParent(tree) {
177
172
*
178
173
* @param {unknown } [node]
179
174
* Thing to assert.
180
- * @returns {asserts node is Literal }
175
+ * @returns {asserts node is Literals }
181
176
* Nothing.
182
177
* @throws {AssertionError }
183
178
* When `node` is not an mdast literal.
0 commit comments