@@ -152,6 +152,7 @@ function root(node, ancestor) {
152152 */
153153function list ( node ) {
154154 parent ( node )
155+ indexable ( node )
155156
156157 if ( node . spread != null ) {
157158 nodeAssert . strictEqual (
@@ -187,6 +188,7 @@ function list(node) {
187188 */
188189function listItem ( node ) {
189190 parent ( node )
191+ indexable ( node )
190192
191193 if ( node . spread != null ) {
192194 nodeAssert . strictEqual (
@@ -211,6 +213,7 @@ function listItem(node) {
211213 */
212214function heading ( node ) {
213215 parent ( node )
216+ indexable ( node )
214217
215218 nodeAssert . ok ( node . depth > 0 , '`depth` should be gte `1`' )
216219 nodeAssert . ok ( node . depth <= 6 , '`depth` should be lte `6`' )
@@ -222,6 +225,7 @@ function heading(node) {
222225 */
223226function code ( node ) {
224227 literal ( node )
228+ indexable ( node )
225229
226230 if ( node . lang != null ) {
227231 nodeAssert . strictEqual (
@@ -247,6 +251,7 @@ function code(node) {
247251 */
248252function footnoteDefinition ( node ) {
249253 parent ( node )
254+ indexable ( node )
250255
251256 nodeAssert . strictEqual (
252257 typeof node . identifier ,
@@ -269,6 +274,7 @@ function footnoteDefinition(node) {
269274 */
270275function definition ( node ) {
271276 _void ( node )
277+ indexable ( node )
272278
273279 nodeAssert . strictEqual (
274280 typeof node . identifier ,
@@ -301,6 +307,7 @@ function definition(node) {
301307 */
302308function link ( node ) {
303309 parent ( node )
310+ indexable ( node )
304311
305312 nodeAssert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
306313
@@ -319,6 +326,7 @@ function link(node) {
319326 */
320327function image ( node ) {
321328 _void ( node )
329+ indexable ( node )
322330
323331 nodeAssert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
324332
@@ -341,6 +349,7 @@ function image(node) {
341349 */
342350function linkReference ( node ) {
343351 parent ( node )
352+ indexable ( node )
344353
345354 nodeAssert . strictEqual (
346355 typeof node . identifier ,
@@ -372,6 +381,7 @@ function linkReference(node) {
372381 */
373382function imageReference ( node ) {
374383 _void ( node )
384+ indexable ( node )
375385
376386 nodeAssert . strictEqual (
377387 typeof node . identifier ,
@@ -407,6 +417,7 @@ function imageReference(node) {
407417 */
408418function footnoteReference ( node ) {
409419 _void ( node )
420+ indexable ( node )
410421
411422 nodeAssert . strictEqual (
412423 typeof node . identifier ,
@@ -435,6 +446,7 @@ function table(node) {
435446 var value
436447
437448 parent ( node )
449+ indexable ( node )
438450
439451 if ( node . align != null ) {
440452 nodeAssert . ok ( Array . isArray ( node . align ) , '`align` must be `array`' )
@@ -454,3 +466,15 @@ function table(node) {
454466 }
455467 }
456468}
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