File tree 4 files changed +15
-7
lines changed
4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import { zwitch } from 'zwitch'
10
10
import { configure } from './configure.js'
11
- import { handle } from './handle/index.js'
11
+ import { handle as handlers } from './handle/index.js'
12
12
import { join } from './join.js'
13
13
import { unsafe } from './unsafe.js'
14
14
@@ -29,14 +29,15 @@ export function toMarkdown(tree, options = {}) {
29
29
stack : [ ] ,
30
30
unsafe : [ ] ,
31
31
join : [ ] ,
32
+ // @ts -expect-error: we’ll fill it next.
32
33
handlers : { } ,
33
34
options : { } ,
34
35
indexStack : [ ] ,
35
36
// @ts -expect-error: we’ll add `handle` later.
36
37
handle : undefined
37
38
}
38
39
39
- configure ( state , { unsafe, join, handlers : handle } )
40
+ configure ( state , { unsafe, join, handlers} )
40
41
configure ( state , options )
41
42
42
43
if ( state . options . tightDefinitions ) {
Original file line number Diff line number Diff line change 80
80
* @returns {string }
81
81
* Serialized markdown representing `node`.
82
82
*
83
- * @typedef {Record<string , Handle> } Handlers
83
+ * @typedef {Record<Node['type'] , Handle> } Handlers
84
84
* Handle particular nodes.
85
85
*
86
86
* Each key is a node type, each value its corresponding handler.
238
238
* }
239
239
* }
240
240
* ```
241
- * @property {Handlers | null | undefined } [handlers={}]
241
+ * @property {Partial< Handlers> | null | undefined } [handlers={}]
242
242
* Handle particular nodes.
243
243
*
244
244
* Each key is a node type, each value its corresponding handler.
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ Serialized markdown representing `node` (`string`).
208
208
209
209
Handle particular nodes (TypeScript type).
210
210
211
- Each key is a node type (` string ` ), each value its corresponding handler
211
+ Each key is a node type (` Node['type'] ` ), each value its corresponding handler
212
212
([ ` Handle ` ] [ handle ] ).
213
213
214
214
###### Type
Original file line number Diff line number Diff line change 1
1
/**
2
2
* @typedef {import('mdast').BlockContent } BlockContent
3
3
* @typedef {import('mdast').List } List
4
+ * @typedef {import('../index.js').Handle } Handle
4
5
*/
5
6
6
7
import assert from 'node:assert/strict'
@@ -3810,7 +3811,10 @@ test('position (output)', function () {
3810
3811
} ,
3811
3812
{
3812
3813
handlers : {
3813
- /** @param {unknown } _ */
3814
+ /**
3815
+ * @type {Handle }
3816
+ * @param {unknown } _
3817
+ */
3814
3818
unknown ( _ , _2 , _3 , info ) {
3815
3819
const { now, lineShift} = info
3816
3820
assert . deepEqual (
@@ -3849,7 +3853,10 @@ test('position (output)', function () {
3849
3853
} ,
3850
3854
{
3851
3855
handlers : {
3852
- /** @param {unknown } _ */
3856
+ /**
3857
+ * @type {Handle }
3858
+ * @param {unknown } _
3859
+ */
3853
3860
unknown ( _ , _2 , _3 , info ) {
3854
3861
const { now, lineShift} = info
3855
3862
assert . deepEqual (
You can’t perform that action at this time.
0 commit comments