Skip to content

Commit 843e046

Browse files
committed
Update @types/mdast and friends
1 parent 13da038 commit 843e046

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

dev/lib/index.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,21 @@
66
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
77
* @typedef {import('micromark-util-types').Value} Value
88
*
9-
* @typedef {import('unist').Parent} UnistParent
109
* @typedef {import('unist').Point} Point
1110
*
11+
* @typedef {import('mdast').Parent} Parent
1212
* @typedef {import('mdast').PhrasingContent} PhrasingContent
13-
* @typedef {import('mdast').StaticPhrasingContent} StaticPhrasingContent
14-
* @typedef {import('mdast').Content} Content
13+
* @typedef {import('mdast').Nodes} Nodes
1514
* @typedef {import('mdast').Break} Break
1615
* @typedef {import('mdast').Blockquote} Blockquote
1716
* @typedef {import('mdast').Code} Code
1817
* @typedef {import('mdast').Definition} Definition
1918
* @typedef {import('mdast').Emphasis} Emphasis
2019
* @typedef {import('mdast').Heading} Heading
21-
* @typedef {import('mdast').HTML} HTML
20+
* @typedef {import('mdast').Html} Html
2221
* @typedef {import('mdast').Image} Image
23-
* @typedef {import('mdast').ImageReference} ImageReference
2422
* @typedef {import('mdast').InlineCode} InlineCode
2523
* @typedef {import('mdast').Link} Link
26-
* @typedef {import('mdast').LinkReference} LinkReference
2724
* @typedef {import('mdast').List} List
2825
* @typedef {import('mdast').ListItem} ListItem
2926
* @typedef {import('mdast').Paragraph} Paragraph
@@ -36,10 +33,8 @@
3633
*/
3734

3835
/**
39-
* @typedef {Root | Content} Node
40-
* @typedef {Extract<Node, UnistParent>} Parent
4136
*
42-
* @typedef {Omit<UnistParent, 'type' | 'children'> & {type: 'fragment', children: Array<PhrasingContent>}} Fragment
37+
* @typedef {Omit<Parent, 'type' | 'children'> & {type: 'fragment', children: Array<PhrasingContent>}} Fragment
4338
*/
4439

4540
/**
@@ -110,7 +105,7 @@
110105
*
111106
* @typedef CompileContext
112107
* mdast compiler context.
113-
* @property {Array<Node | Fragment>} stack
108+
* @property {Array<Nodes | Fragment>} stack
114109
* Stack of nodes.
115110
* @property {Array<TokenTuple>} tokenStack
116111
* Stack of tokens.
@@ -122,9 +117,9 @@
122117
* Capture some of the output data.
123118
* @property {(this: CompileContext) => string} resume
124119
* Stop capturing and access the output data.
125-
* @property {<Kind extends Node>(this: CompileContext, node: Kind, token: Token, onError?: OnEnterError) => Kind} enter
120+
* @property {<Kind extends Nodes>(this: CompileContext, node: Kind, token: Token, onError?: OnEnterError) => Kind} enter
126121
* Enter a token.
127-
* @property {(this: CompileContext, token: Token, onError?: OnExitError) => Node} exit
122+
* @property {(this: CompileContext, token: Token, onError?: OnExitError) => Nodes} exit
128123
* Exit a token.
129124
* @property {TokenizeContext['sliceSerialize']} sliceSerialize
130125
* Get the string value of a token.
@@ -141,7 +136,7 @@
141136
*/
142137

143138
// To do: micromark: create a registry of tokens?
144-
// To do: next major: don’t return given `Node` from `enter`.
139+
// To do: next major: don’t return given `Nodes` from `enter`.
145140
// To do: next major: remove setter/getter.
146141

147142
import {ok as assert} from 'devlop'
@@ -569,7 +564,7 @@ function compiler(options) {
569564
/**
570565
* Create an opener handle.
571566
*
572-
* @param {(token: Token) => Node} create
567+
* @param {(token: Token) => Nodes} create
573568
* Create a node.
574569
* @param {Handle} [and]
575570
* Optional function to also run.
@@ -599,7 +594,7 @@ function compiler(options) {
599594
}
600595

601596
/**
602-
* @template {Node} Kind
597+
* @template {Nodes} Kind
603598
* Node type.
604599
* @this {CompileContext}
605600
* Context.
@@ -654,7 +649,7 @@ function compiler(options) {
654649
* Corresponding token.
655650
* @param {OnExitError | undefined} [onExitError]
656651
* Handle the case where another token is open.
657-
* @returns {Node}
652+
* @returns {Nodes}
658653
* The closed node.
659654
*/
660655
function exit(token, onExitError) {
@@ -1108,8 +1103,7 @@ function compiler(options) {
11081103
setData('inReference', true)
11091104

11101105
if (node.type === 'link') {
1111-
/** @type {Array<StaticPhrasingContent>} */
1112-
// @ts-expect-error: Assume static phrasing content.
1106+
/** @type {Array<PhrasingContent>} */
11131107
const children = fragment.children
11141108

11151109
node.children = children
@@ -1309,7 +1303,7 @@ function compiler(options) {
13091303
return {type: 'break'}
13101304
}
13111305

1312-
/** @returns {HTML} */
1306+
/** @returns {Html} */
13131307
function html() {
13141308
return {type: 'html', value: ''}
13151309
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@
4141
"default": "./index.js"
4242
},
4343
"dependencies": {
44-
"@types/mdast": "^3.0.0",
45-
"@types/unist": "^2.0.0",
44+
"@types/mdast": "^4.0.0",
45+
"@types/unist": "^3.0.0",
4646
"decode-named-character-reference": "^1.0.0",
4747
"devlop": "^1.0.0",
48-
"mdast-util-to-string": "^3.1.0",
48+
"mdast-util-to-string": "^4.0.0",
4949
"micromark": "^4.0.0",
5050
"micromark-util-decode-numeric-character-reference": "^2.0.0",
5151
"micromark-util-decode-string": "^2.0.0",
5252
"micromark-util-normalize-identifier": "^2.0.0",
5353
"micromark-util-symbol": "^2.0.0",
5454
"micromark-util-types": "^2.0.0",
55-
"unist-util-stringify-position": "^3.0.0"
55+
"unist-util-stringify-position": "^4.0.0"
5656
},
5757
"devDependencies": {
5858
"@types/node": "^20.0.0",

0 commit comments

Comments
 (0)