@@ -152,6 +152,7 @@ function root(node, ancestor) {
152
152
*/
153
153
function list ( node ) {
154
154
parent ( node )
155
+ indexable ( node )
155
156
156
157
if ( node . spread != null ) {
157
158
nodeAssert . strictEqual (
@@ -187,6 +188,7 @@ function list(node) {
187
188
*/
188
189
function listItem ( node ) {
189
190
parent ( node )
191
+ indexable ( node )
190
192
191
193
if ( node . spread != null ) {
192
194
nodeAssert . strictEqual (
@@ -211,6 +213,7 @@ function listItem(node) {
211
213
*/
212
214
function heading ( node ) {
213
215
parent ( node )
216
+ indexable ( node )
214
217
215
218
nodeAssert . ok ( node . depth > 0 , '`depth` should be gte `1`' )
216
219
nodeAssert . ok ( node . depth <= 6 , '`depth` should be lte `6`' )
@@ -222,6 +225,7 @@ function heading(node) {
222
225
*/
223
226
function code ( node ) {
224
227
literal ( node )
228
+ indexable ( node )
225
229
226
230
if ( node . lang != null ) {
227
231
nodeAssert . strictEqual (
@@ -247,6 +251,7 @@ function code(node) {
247
251
*/
248
252
function footnoteDefinition ( node ) {
249
253
parent ( node )
254
+ indexable ( node )
250
255
251
256
nodeAssert . strictEqual (
252
257
typeof node . identifier ,
@@ -269,6 +274,7 @@ function footnoteDefinition(node) {
269
274
*/
270
275
function definition ( node ) {
271
276
_void ( node )
277
+ indexable ( node )
272
278
273
279
nodeAssert . strictEqual (
274
280
typeof node . identifier ,
@@ -301,6 +307,7 @@ function definition(node) {
301
307
*/
302
308
function link ( node ) {
303
309
parent ( node )
310
+ indexable ( node )
304
311
305
312
nodeAssert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
306
313
@@ -319,6 +326,7 @@ function link(node) {
319
326
*/
320
327
function image ( node ) {
321
328
_void ( node )
329
+ indexable ( node )
322
330
323
331
nodeAssert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
324
332
@@ -341,6 +349,7 @@ function image(node) {
341
349
*/
342
350
function linkReference ( node ) {
343
351
parent ( node )
352
+ indexable ( node )
344
353
345
354
nodeAssert . strictEqual (
346
355
typeof node . identifier ,
@@ -372,6 +381,7 @@ function linkReference(node) {
372
381
*/
373
382
function imageReference ( node ) {
374
383
_void ( node )
384
+ indexable ( node )
375
385
376
386
nodeAssert . strictEqual (
377
387
typeof node . identifier ,
@@ -407,6 +417,7 @@ function imageReference(node) {
407
417
*/
408
418
function footnoteReference ( node ) {
409
419
_void ( node )
420
+ indexable ( node )
410
421
411
422
nodeAssert . strictEqual (
412
423
typeof node . identifier ,
@@ -435,6 +446,7 @@ function table(node) {
435
446
var value
436
447
437
448
parent ( node )
449
+ indexable ( node )
438
450
439
451
if ( node . align != null ) {
440
452
nodeAssert . ok ( Array . isArray ( node . align ) , '`align` must be `array`' )
@@ -454,3 +466,15 @@ function table(node) {
454
466
}
455
467
}
456
468
}
469
+
470
+ /**
471
+ * @param {unknown } value
472
+ * @returns {asserts value is Record<string, unknown> }
473
+ */
474
+ function indexable ( value ) {
475
+ // Always called when something is an object, this is just for TS.
476
+ /* c8 ignore next 3 */
477
+ if ( ! value || typeof value !== 'object' ) {
478
+ throw new Error ( 'Expected object' )
479
+ }
480
+ }
0 commit comments