Skip to content

Commit 7f21d65

Browse files
Change types to use mdast types
Closes GH-37. Co-authored-by: Christian Murphy <christian.murphy.42@gmail.com>
1 parent eed5115 commit 7f21d65

File tree

6 files changed

+156
-68
lines changed

6 files changed

+156
-68
lines changed

lib/handle/list-item.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function listItem(node, parent, context) {
2020
/** @type {string} */
2121
let bullet = checkBullet(context)
2222

23-
if (parent && parent.ordered) {
23+
if (parent && parent.type === 'list' && parent.ordered) {
2424
bullet =
2525
(typeof parent.start === 'number' && parent.start > -1
2626
? parent.start

lib/join.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ function joinDefaults(left, right, parent, context) {
1717
Boolean(left.ordered) === Boolean(right.ordered)) ||
1818
// Indented code after list or another indented code.
1919
(right.type === 'code' &&
20-
// @ts-expect-error: hush.
2120
formatCodeAsIndented(right, context) &&
2221
(left.type === 'list' ||
23-
// @ts-expect-error: hush.
2422
(left.type === right.type && formatCodeAsIndented(left, context))))
2523
) {
2624
return false
@@ -35,7 +33,6 @@ function joinDefaults(left, right, parent, context) {
3533
(left.type === right.type ||
3634
right.type === 'definition' ||
3735
// Paragraph followed by a setext heading.
38-
// @ts-expect-error: hush.
3936
(right.type === 'heading' && formatHeadingAsSetext(right, context)))
4037
) {
4138
return

lib/types.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/**
2-
* @typedef {import('unist').Node} Node
3-
* @typedef {import('unist').Parent} Parent
2+
* @typedef {import('unist').Parent} UnistParent
3+
* @typedef {import('mdast').Root} Root
4+
* @typedef {import('mdast').Content} Content
5+
* @typedef {Root|Content} Node
6+
* @typedef {Extract<Node, UnistParent>} Parent
47
*/
58

69
/**

lib/util/container-flow.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @typedef {import('unist').Parent} Parent
3-
* @typedef {import('unist').Node} Node
2+
* @typedef {import('../types.js').Node} Node
3+
* @typedef {import('../types.js').Parent} Parent
44
* @typedef {import('../types.js').Join} Join
55
* @typedef {import('../types.js').Context} Context
66
*/

lib/util/container-phrasing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @typedef {import('unist').Node} Node
3-
* @typedef {import('unist').Parent} Parent
2+
* @typedef {import('../types.js').Node} Node
3+
* @typedef {import('../types.js').Parent} Parent
44
* @typedef {import('../types.js').SafeOptions} SafeOptions
55
* @typedef {import('../types.js').Context} Context
66
*/

0 commit comments

Comments
 (0)