|
1 | 1 | /**
|
| 2 | + * @typedef {import('mdast').Content} Content |
2 | 3 | * @typedef {import('mdast').Heading} Heading
|
3 | 4 | * @typedef {import('mdast').Root} Root
|
4 | 5 | * @typedef {import('unist').Node} UnistNode
|
|
89 | 90 | * Node to search for.
|
90 | 91 | */
|
91 | 92 |
|
92 |
| -/** |
93 |
| - * @typedef {Child<Root, Parent<Root, Heading>>} Sibling |
94 |
| - * Collect nodes in `Tree` that can be parents of `Child`. |
95 |
| - * @template {UnistNode} Tree |
96 |
| - * All node types in a tree. |
97 |
| - * @template {UnistNode} Node |
98 |
| - * Node to search for. |
99 |
| - */ |
100 |
| - |
101 | 93 | /**
|
102 | 94 | * @callback Handler
|
103 | 95 | * Callback called when a section is found.
|
104 | 96 | * @param {Heading} start
|
105 | 97 | * Start of section (a heading node matching `test`).
|
106 |
| - * @param {Array<Sibling<Root, Heading>>} between |
| 98 | + * @param {Array<Content>} between |
107 | 99 | * Nodes between `start` and `end`.
|
108 |
| - * @param {Sibling<Root, Heading> | undefined} end |
| 100 | + * @param {Content | undefined} end |
109 | 101 | * End of section, if any.
|
110 | 102 | * @param {Info} scope
|
111 | 103 | * Extra info.
|
112 |
| - * @returns {Array<Sibling<Root, Heading> | null | undefined> | null | undefined | void} |
| 104 | + * @returns {Array<Content | null | undefined> | null | undefined | void} |
113 | 105 | * Results.
|
114 | 106 | *
|
115 | 107 | * If nothing is returned, nothing will be changed.
|
@@ -176,8 +168,6 @@ import {toString} from 'mdast-util-to-string'
|
176 | 168 | // eslint-disable-next-line complexity
|
177 | 169 | export function headingRange(tree, options, handler) {
|
178 | 170 | let test = options
|
179 |
| - // To do: smarter types to allow siblings of headings. |
180 |
| - /** @type {Array<Sibling<Root, Heading>>} */ |
181 | 171 | const children = 'children' in tree ? tree.children : []
|
182 | 172 | let ignoreFinalDefinitions = false
|
183 | 173 |
|
@@ -260,7 +250,7 @@ export function headingRange(tree, options, handler) {
|
260 | 250 | if (nodes) {
|
261 | 251 | // Ensure no empty nodes are inserted.
|
262 | 252 | // This could be the case if `end` is in `nodes` but no `end` node exists.
|
263 |
| - /** @type {Array<Sibling<Root, Heading>>} */ |
| 253 | + /** @type {Array<Content>} */ |
264 | 254 | const result = []
|
265 | 255 | let index = -1
|
266 | 256 |
|
|
0 commit comments