1
- import { color } from './color.js'
2
-
3
1
/**
4
2
* @typedef {import('unist').Node } Node
5
3
* @typedef {import('unist').Position } Position
@@ -9,6 +7,8 @@ import {color} from './color.js'
9
7
* @property {boolean } [showPositions=true]
10
8
*/
11
9
10
+ import { color } from './color.js'
11
+
12
12
/* c8 ignore next */
13
13
export var inspect = color ? inspectColor : inspectNoColor
14
14
@@ -183,6 +183,7 @@ export function inspectColor(tree, options) {
183
183
*/
184
184
function inspectTree ( node ) {
185
185
var result = [ formatNode ( node ) ]
186
+ // @ts -expect-error: looks like a record.
186
187
var fields = inspectFields ( node )
187
188
// @ts -ignore looks like a parent.
188
189
var content = inspectNodes ( node . children || [ ] )
@@ -199,17 +200,22 @@ export function inspectColor(tree, options) {
199
200
*/
200
201
function formatNode ( node ) {
201
202
var result = [ bold ( node . type ) ]
203
+ /** @type {string } */
204
+ // @ts -expect-error: might be available.
202
205
var kind = node . tagName || node . name
203
206
var position = positions ? stringifyPosition ( node . position ) : ''
204
207
205
208
if ( typeof kind === 'string' ) {
206
209
result . push ( '<' , kind , '>' )
207
210
}
208
211
212
+ // @ts -expect-error: looks like a parent.
209
213
if ( node . children ) {
210
214
// @ts -ignore looks like a parent.
211
215
result . push ( dim ( '[' ) , yellow ( node . children . length ) , dim ( ']' ) )
216
+ // @ts -expect-error: looks like a literal.
212
217
} else if ( typeof node . value === 'string' ) {
218
+ // @ts -expect-error: looks like a literal.
213
219
result . push ( ' ' , green ( inspectNonTree ( node . value ) ) )
214
220
}
215
221
0 commit comments