Skip to content

Commit ebf0058

Browse files
committed
Fix to unlock type dependencies
1 parent 1ec35ae commit ebf0058

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

lib/handle/list-item.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export function listItem(node, parent, context) {
3535

3636
if (
3737
listItemIndent === 'tab' ||
38-
(listItemIndent === 'mixed' && ((parent && parent.spread) || node.spread))
38+
(listItemIndent === 'mixed' &&
39+
((parent && 'spread' in parent && parent.spread) || node.spread))
3940
) {
4041
size = Math.ceil(size / 4) * 4
4142
}

lib/join.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function joinDefaults(left, right, parent, context) {
2626

2727
// Join children of a list or an item.
2828
// In which case, `parent` has a `spread` field.
29-
if (typeof parent.spread === 'boolean') {
29+
if ('spread' in parent && typeof parent.spread === 'boolean') {
3030
if (
3131
left.type === 'paragraph' &&
3232
// Two paragraphs.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
"index.js"
3939
],
4040
"dependencies": {
41-
"@types/mdast": "3.0.3",
42-
"@types/unist": "2.0.4",
41+
"@types/mdast": "^3.0.0",
42+
"@types/unist": "^2.0.0",
4343
"longest-streak": "^3.0.0",
4444
"mdast-util-to-string": "^3.0.0",
4545
"parse-entities": "^3.0.0",

test/index.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ test('core', (t) => {
1818
)
1919

2020
t.equal(
21-
// @ts-expect-error: `identifier`, `url` missing.
2221
to({
2322
type: 'root',
2423
children: [
2524
{type: 'paragraph', children: [{type: 'text', value: 'a'}]},
25+
// @ts-expect-error: `identifier`, `url` missing.
2626
{type: 'definition', label: 'b'},
27+
// @ts-expect-error: `identifier`, `url` missing.
2728
{type: 'definition', label: 'c'},
2829
{type: 'paragraph', children: [{type: 'text', value: 'd'}]}
2930
]
@@ -34,12 +35,13 @@ test('core', (t) => {
3435

3536
t.equal(
3637
to(
37-
// @ts-expect-error: `identifier`, `url` missing.
3838
{
3939
type: 'root',
4040
children: [
4141
{type: 'paragraph', children: [{type: 'text', value: 'a'}]},
42+
// @ts-expect-error: `identifier`, `url` missing.
4243
{type: 'definition', label: 'b'},
44+
// @ts-expect-error: `identifier`, `url` missing.
4345
{type: 'definition', label: 'c'},
4446
{type: 'paragraph', children: [{type: 'text', value: 'd'}]}
4547
]
@@ -51,14 +53,17 @@ test('core', (t) => {
5153
)
5254

5355
t.equal(
54-
// @ts-expect-error: `children` missing.
5556
to({
5657
type: 'root',
5758
children: [
5859
{type: 'paragraph', children: [{type: 'text', value: 'a'}]},
60+
// @ts-expect-error: `children` missing.
5961
{type: 'list', children: [{type: 'listItem'}]},
62+
// @ts-expect-error: `children` missing.
6063
{type: 'list', children: [{type: 'listItem'}]},
64+
// @ts-expect-error: `children` missing.
6165
{type: 'list', ordered: true, children: [{type: 'listItem'}]},
66+
// @ts-expect-error: `children` missing.
6267
{type: 'list', ordered: true, children: [{type: 'listItem'}]},
6368
{type: 'paragraph', children: [{type: 'text', value: 'd'}]}
6469
]
@@ -68,11 +73,11 @@ test('core', (t) => {
6873
)
6974

7075
t.equal(
71-
// @ts-expect-error: `children` missing.
7276
to({
7377
type: 'root',
7478
children: [
7579
{type: 'code', value: 'a'},
80+
// @ts-expect-error: `children` missing.
7681
{type: 'list', children: [{type: 'listItem'}]},
7782
{type: 'code', value: 'b'}
7883
]
@@ -107,12 +112,12 @@ test('core', (t) => {
107112
)
108113

109114
t.equal(
110-
// @ts-expect-error: `definition` in `listItem` is fine.
111115
to({
112116
type: 'listItem',
113117
spread: false,
114118
children: [
115119
{type: 'paragraph', children: [{type: 'text', value: 'a'}]},
120+
// @ts-expect-error: `definition` in `listItem` is fine.
116121
{type: 'definition', label: 'b', url: 'c'}
117122
]
118123
}),
@@ -169,9 +174,9 @@ test('core', (t) => {
169174

170175
t.throws(
171176
() => {
172-
// @ts-expect-error: custom node.
173177
to({
174178
type: 'paragraph',
179+
// @ts-expect-error: custom node.
175180
children: [{type: 'text', value: 'a'}, {type: 'unknown'}]
176181
})
177182
},
@@ -336,10 +341,10 @@ test('blockquote', (t) => {
336341
)
337342

338343
t.equal(
339-
// @ts-expect-error: `definition` is fine in `blockquote`.
340344
to({
341345
type: 'blockquote',
342346
children: [
347+
// @ts-expect-error: `definition` is fine in `blockquote`.
343348
{type: 'definition', label: 'a\nb', url: 'c\nd', title: 'e\nf'},
344349
{
345350
type: 'paragraph',
@@ -1878,10 +1883,10 @@ test('linkReference', (t) => {
18781883
)
18791884

18801885
t.equal(
1881-
// @ts-expect-error: `referenceType`, `identifier` missing.
18821886
to({
18831887
type: 'paragraph',
18841888
children: [
1889+
// @ts-expect-error: `referenceType`, `identifier` missing.
18851890
{type: 'linkReference', children: [{type: 'text', value: 'a'}]},
18861891
{type: 'text', value: '(b)'}
18871892
]
@@ -2795,7 +2800,6 @@ test('escape', (t) => {
27952800

27962801
t.equal(
27972802
to(
2798-
// @ts-expect-error: `null` for `checked` is what we’ve always used.
27992803
{
28002804
type: 'root',
28012805
children: [
@@ -2808,6 +2812,7 @@ test('escape', (t) => {
28082812
{
28092813
type: 'listItem',
28102814
spread: true,
2815+
// @ts-expect-error: `null` for `checked` is what we’ve always used.
28112816
checked: null,
28122817
children: [
28132818
{
@@ -2822,12 +2827,14 @@ test('escape', (t) => {
28222827
{
28232828
type: 'list',
28242829
ordered: false,
2830+
// @ts-expect-error: `null` for `start` is what we’ve always used.
28252831
start: null,
28262832
spread: false,
28272833
children: [
28282834
{
28292835
type: 'listItem',
28302836
spread: false,
2837+
// @ts-expect-error: `null` for `checked` is what we’ve always used.
28312838
checked: null,
28322839
children: [
28332840
{

0 commit comments

Comments
 (0)