File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 88
99import { zwitch } from 'zwitch'
1010import { configure } from './configure.js'
11- import { handle } from './handle/index.js'
11+ import { handle as handlers } from './handle/index.js'
1212import { join } from './join.js'
1313import { unsafe } from './unsafe.js'
1414
@@ -29,14 +29,15 @@ export function toMarkdown(tree, options = {}) {
2929 stack : [ ] ,
3030 unsafe : [ ] ,
3131 join : [ ] ,
32+ // @ts -expect-error: we’ll fill it next.
3233 handlers : { } ,
3334 options : { } ,
3435 indexStack : [ ] ,
3536 // @ts -expect-error: we’ll add `handle` later.
3637 handle : undefined
3738 }
3839
39- configure ( state , { unsafe, join, handlers : handle } )
40+ configure ( state , { unsafe, join, handlers} )
4041 configure ( state , options )
4142
4243 if ( state . options . tightDefinitions ) {
Original file line number Diff line number Diff line change 8080 * @returns {string }
8181 * Serialized markdown representing `node`.
8282 *
83- * @typedef {Record<string , Handle> } Handlers
83+ * @typedef {Record<Node['type'] , Handle> } Handlers
8484 * Handle particular nodes.
8585 *
8686 * Each key is a node type, each value its corresponding handler.
238238 * }
239239 * }
240240 * ```
241- * @property {Handlers | null | undefined } [handlers={}]
241+ * @property {Partial< Handlers> | null | undefined } [handlers={}]
242242 * Handle particular nodes.
243243 *
244244 * 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`).
208208
209209Handle particular nodes (TypeScript type).
210210
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
212212([ ` Handle ` ] [ handle ] ).
213213
214214###### Type
Original file line number Diff line number Diff line change 11/**
22 * @typedef {import('mdast').BlockContent } BlockContent
33 * @typedef {import('mdast').List } List
4+ * @typedef {import('../index.js').Handle } Handle
45 */
56
67import assert from 'node:assert/strict'
@@ -3810,7 +3811,10 @@ test('position (output)', function () {
38103811 } ,
38113812 {
38123813 handlers : {
3813- /** @param {unknown } _ */
3814+ /**
3815+ * @type {Handle }
3816+ * @param {unknown } _
3817+ */
38143818 unknown ( _ , _2 , _3 , info ) {
38153819 const { now, lineShift} = info
38163820 assert . deepEqual (
@@ -3849,7 +3853,10 @@ test('position (output)', function () {
38493853 } ,
38503854 {
38513855 handlers : {
3852- /** @param {unknown } _ */
3856+ /**
3857+ * @type {Handle }
3858+ * @param {unknown } _
3859+ */
38533860 unknown ( _ , _2 , _3 , info ) {
38543861 const { now, lineShift} = info
38553862 assert . deepEqual (
You can’t perform that action at this time.
0 commit comments