Skip to content

Commit 3c88de9

Browse files
committed
Fix types for changes in @types/unist
1 parent 594e69a commit 3c88de9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import {color} from './color.js'
2-
31
/**
42
* @typedef {import('unist').Node} Node
53
* @typedef {import('unist').Position} Position
@@ -9,6 +7,8 @@ import {color} from './color.js'
97
* @property {boolean} [showPositions=true]
108
*/
119

10+
import {color} from './color.js'
11+
1212
/* c8 ignore next */
1313
export var inspect = color ? inspectColor : inspectNoColor
1414

@@ -183,6 +183,7 @@ export function inspectColor(tree, options) {
183183
*/
184184
function inspectTree(node) {
185185
var result = [formatNode(node)]
186+
// @ts-expect-error: looks like a record.
186187
var fields = inspectFields(node)
187188
// @ts-ignore looks like a parent.
188189
var content = inspectNodes(node.children || [])
@@ -199,17 +200,22 @@ export function inspectColor(tree, options) {
199200
*/
200201
function formatNode(node) {
201202
var result = [bold(node.type)]
203+
/** @type {string} */
204+
// @ts-expect-error: might be available.
202205
var kind = node.tagName || node.name
203206
var position = positions ? stringifyPosition(node.position) : ''
204207

205208
if (typeof kind === 'string') {
206209
result.push('<', kind, '>')
207210
}
208211

212+
// @ts-expect-error: looks like a parent.
209213
if (node.children) {
210214
// @ts-ignore looks like a parent.
211215
result.push(dim('['), yellow(node.children.length), dim(']'))
216+
// @ts-expect-error: looks like a literal.
212217
} else if (typeof node.value === 'string') {
218+
// @ts-expect-error: looks like a literal.
213219
result.push(' ', green(inspectNonTree(node.value)))
214220
}
215221

0 commit comments

Comments
 (0)