|
6 | 6 | * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
|
7 | 7 | * @typedef {import('micromark-util-types').Value} Value
|
8 | 8 | *
|
9 |
| - * @typedef {import('unist').Parent} UnistParent |
10 | 9 | * @typedef {import('unist').Point} Point
|
11 | 10 | *
|
| 11 | + * @typedef {import('mdast').Parent} Parent |
12 | 12 | * @typedef {import('mdast').PhrasingContent} PhrasingContent
|
13 |
| - * @typedef {import('mdast').StaticPhrasingContent} StaticPhrasingContent |
14 |
| - * @typedef {import('mdast').Content} Content |
| 13 | + * @typedef {import('mdast').Nodes} Nodes |
15 | 14 | * @typedef {import('mdast').Break} Break
|
16 | 15 | * @typedef {import('mdast').Blockquote} Blockquote
|
17 | 16 | * @typedef {import('mdast').Code} Code
|
18 | 17 | * @typedef {import('mdast').Definition} Definition
|
19 | 18 | * @typedef {import('mdast').Emphasis} Emphasis
|
20 | 19 | * @typedef {import('mdast').Heading} Heading
|
21 |
| - * @typedef {import('mdast').HTML} HTML |
| 20 | + * @typedef {import('mdast').Html} Html |
22 | 21 | * @typedef {import('mdast').Image} Image
|
23 |
| - * @typedef {import('mdast').ImageReference} ImageReference |
24 | 22 | * @typedef {import('mdast').InlineCode} InlineCode
|
25 | 23 | * @typedef {import('mdast').Link} Link
|
26 |
| - * @typedef {import('mdast').LinkReference} LinkReference |
27 | 24 | * @typedef {import('mdast').List} List
|
28 | 25 | * @typedef {import('mdast').ListItem} ListItem
|
29 | 26 | * @typedef {import('mdast').Paragraph} Paragraph
|
|
36 | 33 | */
|
37 | 34 |
|
38 | 35 | /**
|
39 |
| - * @typedef {Root | Content} Node |
40 |
| - * @typedef {Extract<Node, UnistParent>} Parent |
41 | 36 | *
|
42 |
| - * @typedef {Omit<UnistParent, 'type' | 'children'> & {type: 'fragment', children: Array<PhrasingContent>}} Fragment |
| 37 | + * @typedef {Omit<Parent, 'type' | 'children'> & {type: 'fragment', children: Array<PhrasingContent>}} Fragment |
43 | 38 | */
|
44 | 39 |
|
45 | 40 | /**
|
|
110 | 105 | *
|
111 | 106 | * @typedef CompileContext
|
112 | 107 | * mdast compiler context.
|
113 |
| - * @property {Array<Node | Fragment>} stack |
| 108 | + * @property {Array<Nodes | Fragment>} stack |
114 | 109 | * Stack of nodes.
|
115 | 110 | * @property {Array<TokenTuple>} tokenStack
|
116 | 111 | * Stack of tokens.
|
|
122 | 117 | * Capture some of the output data.
|
123 | 118 | * @property {(this: CompileContext) => string} resume
|
124 | 119 | * 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 |
126 | 121 | * Enter a token.
|
127 |
| - * @property {(this: CompileContext, token: Token, onError?: OnExitError) => Node} exit |
| 122 | + * @property {(this: CompileContext, token: Token, onError?: OnExitError) => Nodes} exit |
128 | 123 | * Exit a token.
|
129 | 124 | * @property {TokenizeContext['sliceSerialize']} sliceSerialize
|
130 | 125 | * Get the string value of a token.
|
|
141 | 136 | */
|
142 | 137 |
|
143 | 138 | // 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`. |
145 | 140 | // To do: next major: remove setter/getter.
|
146 | 141 |
|
147 | 142 | import {ok as assert} from 'devlop'
|
@@ -569,7 +564,7 @@ function compiler(options) {
|
569 | 564 | /**
|
570 | 565 | * Create an opener handle.
|
571 | 566 | *
|
572 |
| - * @param {(token: Token) => Node} create |
| 567 | + * @param {(token: Token) => Nodes} create |
573 | 568 | * Create a node.
|
574 | 569 | * @param {Handle} [and]
|
575 | 570 | * Optional function to also run.
|
@@ -599,7 +594,7 @@ function compiler(options) {
|
599 | 594 | }
|
600 | 595 |
|
601 | 596 | /**
|
602 |
| - * @template {Node} Kind |
| 597 | + * @template {Nodes} Kind |
603 | 598 | * Node type.
|
604 | 599 | * @this {CompileContext}
|
605 | 600 | * Context.
|
@@ -654,7 +649,7 @@ function compiler(options) {
|
654 | 649 | * Corresponding token.
|
655 | 650 | * @param {OnExitError | undefined} [onExitError]
|
656 | 651 | * Handle the case where another token is open.
|
657 |
| - * @returns {Node} |
| 652 | + * @returns {Nodes} |
658 | 653 | * The closed node.
|
659 | 654 | */
|
660 | 655 | function exit(token, onExitError) {
|
@@ -1108,8 +1103,7 @@ function compiler(options) {
|
1108 | 1103 | setData('inReference', true)
|
1109 | 1104 |
|
1110 | 1105 | if (node.type === 'link') {
|
1111 |
| - /** @type {Array<StaticPhrasingContent>} */ |
1112 |
| - // @ts-expect-error: Assume static phrasing content. |
| 1106 | + /** @type {Array<PhrasingContent>} */ |
1113 | 1107 | const children = fragment.children
|
1114 | 1108 |
|
1115 | 1109 | node.children = children
|
@@ -1309,7 +1303,7 @@ function compiler(options) {
|
1309 | 1303 | return {type: 'break'}
|
1310 | 1304 | }
|
1311 | 1305 |
|
1312 |
| - /** @returns {HTML} */ |
| 1306 | + /** @returns {Html} */ |
1313 | 1307 | function html() {
|
1314 | 1308 | return {type: 'html', value: ''}
|
1315 | 1309 | }
|
|
0 commit comments