Skip to content

Commit 0690696

Browse files
committed
Fix types for handlers
1 parent f8bcef4 commit 0690696

File tree

7 files changed

+19
-6
lines changed

7 files changed

+19
-6
lines changed

lib/handle/break.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/**
22
* @typedef {import('../types.js').Handle} Handle
3+
* @typedef {import('mdast').Break} Break
34
*/
45

56
import {patternInScope} from '../util/pattern-in-scope.js'
67

78
/**
89
* @type {Handle}
10+
* @param {Break} _
911
*/
1012
export function hardBreak(_, _1, context, safe) {
1113
let index = -1

lib/handle/emphasis.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function emphasis(node, _, context) {
2929

3030
/**
3131
* @type {Handle}
32+
* @param {Emphasis} _
3233
*/
3334
function emphasisPeek(_, _1, context) {
3435
return context.options.emphasis || '*'

lib/handle/strong.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function strong(node, _, context) {
2929

3030
/**
3131
* @type {Handle}
32+
* @param {Strong} _
3233
*/
3334
function strongPeek(_, _1, context) {
3435
return context.options.strong || '*'

lib/handle/thematic-break.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/**
22
* @typedef {import('../types.js').Handle} Handle
3+
* @typedef {import('mdast').ThematicBreak} ThematicBreak
34
*/
45

56
import {checkRuleRepetition} from '../util/check-rule-repetition.js'
67
import {checkRule} from '../util/check-rule.js'
78

89
/**
910
* @type {Handle}
11+
* @param {ThematicBreak} _
1012
*/
1113
export function thematicBreak(_, _1, context) {
1214
const value = (

lib/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ export function toMarkdown(tree, options = {}) {
3939
}
4040

4141
/** @type {Handle} */
42-
// @ts-expect-error: hush.
4342
context.handle = zwitch('type', {
44-
// @ts-expect-error: hush.
4543
invalid,
4644
// @ts-expect-error: hush.
4745
unknown,
@@ -72,12 +70,18 @@ export function toMarkdown(tree, options = {}) {
7270
}
7371
}
7472

75-
/** @type {Handle} */
73+
/**
74+
* @type {Handle}
75+
* @param {unknown} value
76+
*/
7677
function invalid(value) {
7778
throw new Error('Cannot handle value `' + value + '`, expected node')
7879
}
7980

80-
/** @type {Handle} */
81+
/**
82+
* @type {Handle}
83+
* @param {Node} node
84+
*/
8185
function unknown(node) {
8286
throw new Error('Cannot handle unknown node `' + node.type + '`')
8387
}

lib/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
/**
3535
* @callback Handle
36-
* @param {Node} node
36+
* @param {any} node
3737
* @param {Parent|null|undefined} parent
3838
* @param {Context} context
3939
* @param {SafeOptions} safeOptions

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
"atLeast": 100,
9191
"detail": true,
9292
"strict": true,
93-
"ignoreCatch": true
93+
"ignoreCatch": true,
94+
"ignoreFiles": [
95+
"lib/types.d.ts"
96+
]
9497
}
9598
}

0 commit comments

Comments
 (0)