Skip to content

Commit 0f4a302

Browse files
committed
Update @types/mdast
1 parent 2a50304 commit 0f4a302

File tree

3 files changed

+19
-28
lines changed

3 files changed

+19
-28
lines changed

index.test-d.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
import {expectType, expectNotType} from 'tsd'
2-
import type {Parent as UnistParent} from 'unist'
3-
import type {Root, Content} from 'mdast'
2+
import type {Nodes, Parents} from 'mdast'
43
import {assert, parent} from './index.js'
54

6-
type Node = Root | Content
7-
type Parent = Extract<Node, UnistParent>
8-
95
const emptyNode = {type: 'doctype'}
106
const literalNode = {type: 'text', value: 'a'}
117
const parentNode = {type: 'element', children: [emptyNode, literalNode]}
128

13-
expectNotType<Node>(emptyNode)
14-
expectNotType<Node>(literalNode)
15-
expectNotType<Node>(parentNode)
9+
expectNotType<Nodes>(emptyNode)
10+
expectNotType<Nodes>(literalNode)
11+
expectNotType<Nodes>(parentNode)
1612

1713
assert(emptyNode)
18-
expectType<Node>(emptyNode)
14+
expectType<Nodes>(emptyNode)
1915

20-
expectNotType<Parent>(parentNode)
16+
expectNotType<Parents>(parentNode)
2117
parent(parentNode)
22-
expectType<Parent>(parentNode)
18+
expectType<Parents>(parentNode)

lib/index.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* @typedef {import('unist-util-assert').AssertionError} AssertionError
33
*
4-
* @typedef {import('unist').Node} UnistNode
54
* @typedef {import('unist').Parent} UnistParent
6-
* @typedef {import('unist').Literal} UnistLiteral
75
*
86
* @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
1010
* @typedef {import('mdast').List} List
1111
* @typedef {import('mdast').ListItem} ListItem
1212
* @typedef {import('mdast').Heading} Heading
@@ -21,11 +21,6 @@
2121
* @typedef {import('mdast').Table} Table
2222
*/
2323

24-
/**
25-
* @typedef {Root | Content} Node
26-
* @typedef {Extract<Node, UnistParent>} Parent
27-
* @typedef {Extract<Node, UnistLiteral>} Literal
28-
*/
2924
import nodeAssert from 'node:assert'
3025
import {zwitch} from 'zwitch'
3126
import {mapz} from 'mapz'
@@ -48,7 +43,7 @@ import {
4843
* Thing to assert.
4944
* @param {UnistParent | null | undefined} [parent]
5045
* Optional, valid parent.
51-
* @returns {asserts tree is Node}
46+
* @returns {asserts tree is Nodes}
5247
* Nothing.
5348
* @throws {AssertionError}
5449
* When `tree` (or its descendants) is not an mdast node.
@@ -68,7 +63,7 @@ export function assert(tree, parent) {
6863
* Thing to assert.
6964
* @param {UnistParent | null | undefined} [parent]
7065
* Optional, valid parent.
71-
* @returns {asserts tree is Parent}
66+
* @returns {asserts tree is Parents}
7267
* Nothing.
7368
* @throws {AssertionError}
7469
* When `tree` is not a parent or its descendants are not nodes.
@@ -86,7 +81,7 @@ export function parent(tree, parent) {
8681
* Thing to assert.
8782
* @param {UnistParent | null | undefined} [parent]
8883
* Optional, valid parent.
89-
* @returns {asserts node is Literal}
84+
* @returns {asserts node is Literals}
9085
* Nothing.
9186
* @throws {AssertionError}
9287
* When `node` is not an mdast literal.
@@ -142,7 +137,7 @@ const all = mapz(mdast, {key: 'children'})
142137
* Thing to assert.
143138
* @param {UnistParent | null | undefined} [parent]
144139
* Optional, valid parent.
145-
* @returns {asserts node is UnistNode}
140+
* @returns {asserts node is Nodes}
146141
* Nothing.
147142
* @throws {AssertionError}
148143
* When `node` is not a unist node.
@@ -160,7 +155,7 @@ function unknown(node, parent) {
160155
*
161156
* @param {unknown} [tree]
162157
* Thing to assert.
163-
* @returns {asserts tree is Parent}
158+
* @returns {asserts tree is Parents}
164159
* Nothing.
165160
* @throws {AssertionError}
166161
* When `tree` is not a parent or its descendants are not nodes.
@@ -177,7 +172,7 @@ function assertParent(tree) {
177172
*
178173
* @param {unknown} [node]
179174
* Thing to assert.
180-
* @returns {asserts node is Literal}
175+
* @returns {asserts node is Literals}
181176
* Nothing.
182177
* @throws {AssertionError}
183178
* When `node` is not an mdast literal.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
"index.js"
3434
],
3535
"dependencies": {
36-
"@types/mdast": "^3.0.0",
37-
"@types/unist": "^2.0.0",
36+
"@types/mdast": "^4.0.0",
37+
"@types/unist": "^3.0.0",
3838
"mapz": "^2.0.0",
39-
"unist-util-assert": "^3.0.0",
39+
"unist-util-assert": "^4.0.0",
4040
"zwitch": "^2.0.0"
4141
},
4242
"devDependencies": {

0 commit comments

Comments
 (0)