Skip to content

Commit cc4e5c5

Browse files
committed
Update @types/hast, utilities
1 parent 8c21532 commit cc4e5c5

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

lib/index.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* @typedef {import('unist').Point} Point
66
* @typedef {import('hast').Element} Element
77
* @typedef {import('hast').Root} Root
8-
* @typedef {import('hast').Content} Content
8+
* @typedef {import('hast').RootContent} RootContent
9+
* @typedef {import('hast').Nodes} Nodes
910
* @typedef {import('parse5').DefaultTreeAdapterMap} DefaultTreeAdapterMap
1011
* @typedef {import('parse5').Token.ElementLocation} P5ElementLocation
1112
* @typedef {import('parse5').Token.Location} P5Location
1213
*/
1314

1415
/**
15-
* @typedef {Content | Root} Node
1616
* @typedef {DefaultTreeAdapterMap['document']} P5Document
1717
* @typedef {DefaultTreeAdapterMap['documentFragment']} P5DocumentFragment
1818
* @typedef {DefaultTreeAdapterMap['documentType']} P5DocumentType
@@ -72,7 +72,7 @@ const proto = Object.prototype
7272
* `parse5` tree to transform.
7373
* @param {Options | VFile | null | undefined} [options]
7474
* Configuration.
75-
* @returns {Node}
75+
* @returns {Nodes}
7676
* hast tree.
7777
*/
7878
export function fromParse5(tree, options) {
@@ -108,11 +108,11 @@ export function fromParse5(tree, options) {
108108
* Info passed around about the current state.
109109
* @param {P5Node} node
110110
* p5 node.
111-
* @returns {Node}
111+
* @returns {Nodes}
112112
* hast node.
113113
*/
114114
function one(state, node) {
115-
/** @type {Node} */
115+
/** @type {Nodes} */
116116
let result
117117

118118
switch (node.nodeName) {
@@ -151,7 +151,6 @@ function one(state, node) {
151151

152152
case '#documentType': {
153153
const reference = /** @type {P5DocumentType} */ (node)
154-
// @ts-expect-error Types are out of date.
155154
result = {type: 'doctype'}
156155
patch(state, reference, result)
157156
return result
@@ -180,12 +179,12 @@ function one(state, node) {
180179
* Info passed around about the current state.
181180
* @param {Array<P5Node>} nodes
182181
* Nodes.
183-
* @returns {Array<Content>}
182+
* @returns {Array<RootContent>}
184183
* hast nodes.
185184
*/
186185
function all(state, nodes) {
187186
let index = -1
188-
/** @type {Array<Content>} */
187+
/** @type {Array<RootContent>} */
189188
const result = []
190189

191190
while (++index < nodes.length) {
@@ -260,7 +259,7 @@ function element(state, node) {
260259
* Info passed around about the current state.
261260
* @param {P5Node} from
262261
* p5 node.
263-
* @param {Node} to
262+
* @param {Nodes} to
264263
* hast node.
265264
* @returns {void}
266265
* Nothing.
@@ -281,7 +280,7 @@ function patch(state, from, to) {
281280
*
282281
* @param {State} state
283282
* Info passed around about the current state.
284-
* @param {Node} node
283+
* @param {Nodes} node
285284
* hast node.
286285
* @param {P5ElementLocation} location
287286
* p5 location info.

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
"index.js"
3434
],
3535
"dependencies": {
36-
"@types/hast": "^2.0.0",
37-
"@types/unist": "^2.0.0",
38-
"hastscript": "^7.0.0",
36+
"@types/hast": "^3.0.0",
37+
"@types/unist": "^3.0.0",
38+
"hastscript": "^8.0.0",
3939
"property-information": "^6.0.0",
40-
"vfile": "^5.0.0",
41-
"vfile-location": "^4.0.0",
40+
"vfile": "^6.0.0",
41+
"vfile-location": "^5.0.0",
4242
"web-namespaces": "^2.0.0"
4343
},
4444
"devDependencies": {
@@ -49,10 +49,10 @@
4949
"prettier": "^3.0.0",
5050
"remark-cli": "^11.0.0",
5151
"remark-preset-wooorm": "^9.0.0",
52-
"to-vfile": "^7.0.0",
52+
"to-vfile": "^8.0.0",
5353
"type-coverage": "^2.0.0",
5454
"typescript": "^5.0.0",
55-
"unist-util-visit": "^4.0.0",
55+
"unist-util-visit": "^5.0.0",
5656
"xo": "^0.55.0"
5757
},
5858
"scripts": {

test/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @typedef {import('vfile').VFile} VFile
3-
* @typedef {import('../lib/index.js').Node} Node
3+
* @typedef {import('hast').Nodes} Nodes
44
*
55
* @typedef Config
66
* @property {VFile} file
@@ -398,7 +398,7 @@ test('fixtures', async () => {
398398
sourceCodeLocationInfo: true
399399
})
400400
const actual = fromParse5(input, {file: options.file, verbose: true})
401-
/** @type {Node} */
401+
/** @type {Nodes} */
402402
let expected
403403

404404
try {
@@ -422,7 +422,7 @@ test('fixtures', async () => {
422422
async function checkNoYes(options) {
423423
const input = parse(String(options.file))
424424
const actual = fromParse5(input, {file: options.file, verbose: true})
425-
/** @type {Node} */
425+
/** @type {Nodes} */
426426
const expected = JSON.parse(String(await fs.readFile(options.out)))
427427

428428
clean(expected)
@@ -442,7 +442,7 @@ test('fixtures', async () => {
442442
sourceCodeLocationInfo: true
443443
})
444444
const actual = fromParse5(input)
445-
/** @type {Node} */
445+
/** @type {Nodes} */
446446
const expected = JSON.parse(String(await fs.readFile(options.out)))
447447

448448
clean(expected)
@@ -460,7 +460,7 @@ test('fixtures', async () => {
460460
async function checkNoNo(options) {
461461
const input = parse(String(options.file))
462462
const actual = fromParse5(input)
463-
/** @type {Node} */
463+
/** @type {Nodes} */
464464
const expected = JSON.parse(String(await fs.readFile(options.out)))
465465

466466
clean(expected)
@@ -474,7 +474,7 @@ test('fixtures', async () => {
474474
})
475475

476476
/**
477-
* @param {Node} tree
477+
* @param {Nodes} tree
478478
*/
479479
function clean(tree) {
480480
visit(tree, (node) => {

0 commit comments

Comments
 (0)