Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit b37a8d1

Browse files
committed
Fix for changes in @types/unist
1 parent 44e4f67 commit b37a8d1

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ function enterFootnoteDefinitionLabelString() {
6161
/** @type {FromMarkdownHandle} */
6262
function exitFootnoteDefinitionLabelString(token) {
6363
const label = this.resume()
64-
this.stack[this.stack.length - 1].label = label
65-
this.stack[this.stack.length - 1].identifier = normalizeIdentifier(
64+
const node = /** @type {FootnoteDefinition} */ (
65+
this.stack[this.stack.length - 1]
66+
)
67+
node.label = label
68+
node.identifier = normalizeIdentifier(
6669
this.sliceSerialize(token)
6770
).toLowerCase()
6871
}
@@ -85,8 +88,11 @@ function enterFootnoteCallString() {
8588
/** @type {FromMarkdownHandle} */
8689
function exitFootnoteCallString(token) {
8790
const label = this.resume()
88-
this.stack[this.stack.length - 1].label = label
89-
this.stack[this.stack.length - 1].identifier = normalizeIdentifier(
91+
const node = /** @type {FootnoteDefinition} */ (
92+
this.stack[this.stack.length - 1]
93+
)
94+
node.label = label
95+
node.identifier = normalizeIdentifier(
9096
this.sliceSerialize(token)
9197
).toLowerCase()
9298
}

test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ test('mdast -> markdown', (t) => {
175175

176176
t.deepEqual(
177177
toMarkdown(
178+
// @ts-expect-error: `identifier` missing.
178179
{type: 'footnoteReference', label: 'X]Y'},
179180
{extensions: [footnoteToMarkdown]}
180181
),
@@ -188,7 +189,7 @@ test('mdast -> markdown', (t) => {
188189
type: 'paragraph',
189190
children: [
190191
{type: 'text', value: 'a'},
191-
{type: 'footnoteReference', label: 'b'},
192+
{type: 'footnoteReference', label: 'b', identifier: 'b'},
192193
{type: 'text', value: 'c'}
193194
]
194195
},
@@ -199,6 +200,7 @@ test('mdast -> markdown', (t) => {
199200
)
200201

201202
t.deepEqual(
203+
// @ts-expect-error: `children` missing.
202204
toMarkdown({type: 'footnote'}, {extensions: [footnoteToMarkdown]}),
203205
'^[]\n',
204206
'should serialize an empty footnote'
@@ -231,6 +233,7 @@ test('mdast -> markdown', (t) => {
231233

232234
t.deepEqual(
233235
toMarkdown(
236+
// @ts-expect-error: `children` missing.
234237
{type: 'footnoteDefinition', identifier: 'a'},
235238
{extensions: [footnoteToMarkdown]}
236239
),
@@ -240,6 +243,7 @@ test('mdast -> markdown', (t) => {
240243

241244
t.deepEqual(
242245
toMarkdown(
246+
// @ts-expect-error: `identifier` missing.
243247
{type: 'footnoteDefinition', label: 'X]Y'},
244248
{extensions: [footnoteToMarkdown]}
245249
),
@@ -252,6 +256,7 @@ test('mdast -> markdown', (t) => {
252256
{
253257
type: 'footnoteDefinition',
254258
label: 'a',
259+
identifier: 'a',
255260
children: [
256261
{type: 'paragraph', children: [{type: 'text', value: 'b\nc'}]},
257262
{type: 'paragraph', children: [{type: 'text', value: 'd'}]}
@@ -268,6 +273,7 @@ test('mdast -> markdown', (t) => {
268273
{
269274
type: 'footnoteDefinition',
270275
label: 'a',
276+
identifier: 'a',
271277
children: [{type: 'code', value: 'b'}]
272278
},
273279
{extensions: [footnoteToMarkdown]}
@@ -281,6 +287,7 @@ test('mdast -> markdown', (t) => {
281287
{
282288
type: 'footnoteDefinition',
283289
label: 'a',
290+
identifier: 'a',
284291
children: [
285292
{type: 'paragraph', children: [{type: 'text', value: 'b'}]},
286293
{type: 'code', value: 'c'}

0 commit comments

Comments
 (0)