Skip to content

Commit 900cf9a

Browse files
committed
Update @types/mdast
1 parent 156f9f8 commit 900cf9a

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

lib/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
/**
2-
* @typedef {import('mdast').Root} Root
3-
* @typedef {import('mdast').Content} Content
2+
* @typedef {import('mdast').Nodes} Nodes
43
* @typedef {import('mdast').Definition} Definition
54
*/
65

76
/**
8-
* @typedef {Root | Content} Node
9-
*
107
* @callback GetDefinition
118
* Get a definition by identifier.
129
* @param {string | null | undefined} [identifier]
@@ -25,7 +22,7 @@ const own = {}.hasOwnProperty
2522
* Uses CommonMark precedence, which means that earlier definitions are
2623
* preferred over duplicate later definitions.
2724
*
28-
* @param {Node} tree
25+
* @param {Nodes} tree
2926
* Tree to check.
3027
* @returns {GetDefinition}
3128
* Getter.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
"index.js"
3737
],
3838
"dependencies": {
39-
"@types/mdast": "^3.0.0",
40-
"@types/unist": "^2.0.0",
41-
"unist-util-visit": "^4.0.0"
39+
"@types/mdast": "^4.0.0",
40+
"@types/unist": "^3.0.0",
41+
"unist-util-visit": "^5.0.0"
4242
},
4343
"devDependencies": {
4444
"@types/node": "^20.0.0",

test.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @typedef {import('mdast').Root} Root
3+
*/
4+
15
import assert from 'node:assert/strict'
26
import test from 'node:test'
37
import {fromMarkdown} from 'mdast-util-from-markdown'
@@ -21,9 +25,7 @@ test('definitions', () => {
2125
)
2226

2327
assert.deepEqual(
24-
definitions(fromMarkdown('[example]: https://example.com "Example"'))(
25-
'example'
26-
),
28+
definitions(from('[example]: https://example.com "Example"'))('example'),
2729
{
2830
type: 'definition',
2931
identifier: 'example',
@@ -39,17 +41,13 @@ test('definitions', () => {
3941
)
4042

4143
assert.equal(
42-
definitions(fromMarkdown('[example]: https://example.com "Example"'))(
43-
'foo'
44-
),
44+
definitions(from('[example]: https://example.com "Example"'))('foo'),
4545
null,
4646
'should return null when not found'
4747
)
4848

4949
assert.deepEqual(
50-
definitions(fromMarkdown('[__proto__]: https://proto.com "Proto"'))(
51-
'__proto__'
52-
),
50+
definitions(from('[__proto__]: https://proto.com "Proto"'))('__proto__'),
5351
{
5452
type: 'definition',
5553
identifier: '__proto__',
@@ -71,15 +69,13 @@ test('definitions', () => {
7169
/* eslint-enable no-use-extend-native/no-use-extend-native */
7270

7371
assert.deepEqual(
74-
definitions(fromMarkdown('[__proto__]: https://proto.com "Proto"'))(
75-
'toString'
76-
),
72+
definitions(from('[__proto__]: https://proto.com "Proto"'))('toString'),
7773
null,
7874
'should work on weird identifiers when not found'
7975
)
8076

8177
const example = definitions(
82-
fromMarkdown('[example]: https://one.com\n[example]: https://two.com')
78+
from('[example]: https://one.com\n[example]: https://two.com')
8379
)('example')
8480

8581
assert.deepEqual(
@@ -89,10 +85,20 @@ test('definitions', () => {
8985
)
9086

9187
assert.deepEqual(
92-
definitions(
93-
fromMarkdown('[example]: https://one.com\n[example]: https://two.com')
94-
)(''),
88+
definitions(from('[example]: https://one.com\n[example]: https://two.com'))(
89+
''
90+
),
9591
null,
9692
'should not return something for a missing identifier'
9793
)
9894
})
95+
96+
/**
97+
*
98+
* @param {string} value
99+
* @returns {Root}
100+
*/
101+
function from(value) {
102+
// @ts-expect-error: To do: remove cast when `from-markdown` is released.
103+
return fromMarkdown(value)
104+
}

0 commit comments

Comments
 (0)