Skip to content

Commit 748d070

Browse files
committed
Fix for changes in @types/unist
1 parent f2a012c commit 748d070

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export function headingRange(node, options, handler) {
8282
child = children[index]
8383

8484
if (child.type === 'heading') {
85+
// @ts-expect-error: looks like a heading.
8586
if (depth && child.depth <= depth) {
8687
end = index
8788
break

test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @typedef {import('tape').Test} Test
33
* @typedef {import('unist').Node} Node
4+
* @typedef {import('mdast').Root} Root
45
* @typedef {import('./index.js').Test | import('./index.js').Options} Options
56
*/
67

@@ -15,15 +16,23 @@ test('mdast-util-heading-range()', function (t) {
1516

1617
t.throws(
1718
function () {
18-
headingRange({type: 'root', chilren: []}, null, function () {})
19+
headingRange(
20+
/** @type {Root} */ ({type: 'root', children: []}),
21+
null,
22+
function () {}
23+
)
1924
},
2025
/^TypeError: Expected `string`, `regexp`, or `function` for `test`, not `null`$/,
2126
'should throw when `null` is passed in'
2227
)
2328

2429
t.throws(
2530
function () {
26-
headingRange({type: 'root', chilren: []}, undefined, function () {})
31+
headingRange(
32+
/** @type {Root} */ ({type: 'root', children: []}),
33+
undefined,
34+
function () {}
35+
)
2736
},
2837
/^TypeError: Expected `string`, `regexp`, or `function` for `test`, not `undefined`$/,
2938
'should throw when `undefined` is passed in'

0 commit comments

Comments
 (0)