@@ -57,13 +57,13 @@ export function inspectColor(tree, options = {}) {
57
57
*/
58
58
function inspectValue ( node ) {
59
59
if ( node && typeof node === 'object' && 'length' in node ) {
60
- // @ts -ignore looks like a list of nodes.
60
+ // @ts -expect-error looks like a list of nodes.
61
61
return inspectNodes ( node )
62
62
}
63
63
64
- // @ts -ignore looks like a single node.
64
+ // @ts -expect-error looks like a single node.
65
65
if ( node && node . type ) {
66
- // @ts -ignore looks like a single node.
66
+ // @ts -expect-error looks like a single node.
67
67
return inspectTree ( node )
68
68
}
69
69
@@ -139,24 +139,26 @@ export function inspectColor(tree, options = {}) {
139
139
if (
140
140
value &&
141
141
typeof value === 'object' &&
142
- // @ts -ignore looks like a node.
142
+ // @ts -expect-error looks like a node.
143
143
value . type &&
144
144
key !== 'data' &&
145
145
key !== 'attributes' &&
146
146
key !== 'properties'
147
147
) {
148
- // @ts -ignore looks like a node.
148
+ // @ts -expect-error looks like a node.
149
149
formatted = inspectTree ( value )
150
150
}
151
151
// A list of nodes.
152
152
else if (
153
153
value &&
154
- typeof value === 'object' &&
155
- 'length' in value &&
154
+ Array . isArray ( value ) &&
155
+ // Looks like a node.
156
+ // type-coverage:ignore-next-line
156
157
value [ 0 ] &&
158
+ // Looks like a node.
159
+ // type-coverage:ignore-next-line
157
160
value [ 0 ] . type
158
161
) {
159
- // @ts -ignore looks like a list of nodes.
160
162
formatted = '\n' + inspectNodes ( value )
161
163
} else {
162
164
formatted = inspectNonTree ( value )
@@ -169,7 +171,7 @@ export function inspectColor(tree, options = {}) {
169
171
170
172
return indent (
171
173
result . join ( '\n' ) ,
172
- // @ts -ignore looks like a parent node.
174
+ // @ts -expect-error looks like a parent node.
173
175
( object . children && object . children . length > 0 ? dim ( '│' ) : ' ' ) + ' '
174
176
)
175
177
}
@@ -182,7 +184,7 @@ export function inspectColor(tree, options = {}) {
182
184
const result = [ formatNode ( node ) ]
183
185
// @ts -expect-error: looks like a record.
184
186
const fields = inspectFields ( node )
185
- // @ts -ignore looks like a parent.
187
+ // @ts -expect-error looks like a parent.
186
188
const content = inspectNodes ( node . children || [ ] )
187
189
if ( fields ) result . push ( fields )
188
190
if ( content ) result . push ( content )
@@ -208,7 +210,7 @@ export function inspectColor(tree, options = {}) {
208
210
209
211
// @ts -expect-error: looks like a parent.
210
212
if ( node . children ) {
211
- // @ts -ignore looks like a parent.
213
+ // @ts -expect-error looks like a parent.
212
214
result . push ( dim ( '[' ) , yellow ( node . children . length ) , dim ( ']' ) )
213
215
// @ts -expect-error: looks like a literal.
214
216
} else if ( typeof node . value === 'string' ) {
@@ -244,12 +246,12 @@ function indent(value, indentation, ignoreFirst) {
244
246
}
245
247
246
248
/**
247
- * @param {Position } value
249
+ * @param {Position|undefined } [ value]
248
250
* @returns {string }
249
251
*/
250
252
function stringifyPosition ( value ) {
251
253
/** @type {Position } */
252
- // @ts -ignore
254
+ // @ts -expect-error: fine.
253
255
const position = value || { }
254
256
/** @type {Array.<string> } */
255
257
const result = [ ]
0 commit comments