Skip to content

Commit 2e44b27

Browse files
committed
Update @types/nlcst, utilities
1 parent d951651 commit 2e44b27

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
"index.js"
3333
],
3434
"dependencies": {
35-
"@types/nlcst": "^1.0.0",
36-
"@types/unist": "^2.0.0",
37-
"nlcst-to-string": "^3.0.0"
35+
"@types/nlcst": "^2.0.0",
36+
"@types/unist": "^3.0.0",
37+
"nlcst-to-string": "^4.0.0"
3838
},
3939
"devDependencies": {
4040
"@types/node": "^20.0.0",
@@ -45,7 +45,7 @@
4545
"remark-preset-wooorm": "^9.0.0",
4646
"type-coverage": "^2.0.0",
4747
"typescript": "^5.0.0",
48-
"unist-util-visit": "^4.0.0",
48+
"unist-util-visit": "^5.0.0",
4949
"xo": "^0.55.0"
5050
},
5151
"scripts": {

test.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
/**
2-
* @typedef {import('unist').Parent} UnistParent
32
* @typedef {import('nlcst').Root} Root
4-
* @typedef {import('nlcst').Word} Word
5-
* @typedef {import('nlcst').Content} Content
6-
* @typedef {Root|Content} Node
7-
* @typedef {Extract<Node, UnistParent>} Parent
8-
* @typedef {import('unist-util-visit/complex-types.js').Visitor<Word>} Visitor
3+
* @typedef {import('unist-util-visit').BuildVisitor<Root, 'WordNode'>} Visitor
94
*/
105

116
import assert from 'node:assert/strict'
@@ -65,10 +60,9 @@ test('isLiteral()', () => {
6560
}, 'should not throw if `node` is in `parent`')
6661

6762
assert.doesNotThrow(() => {
68-
process('Well? Ha! Funky', (_, index, parent_) => {
69-
const parent = /** @type {Parent} */ (parent_)
63+
process('Well? Ha! Funky', (_, index, parent) => {
7064
assert.strictEqual(
71-
parent && index !== null && isLiteral(parent, index),
65+
parent && index !== undefined && isLiteral(parent, index),
7266
false
7367
)
7468
})
@@ -89,10 +83,9 @@ test('isLiteral()', () => {
8983
let index = -1
9084

9185
while (++index < fixtures.length) {
92-
process(fixtures[index], (_, index, parent_) => {
93-
const parent = /** @type {Parent} */ (parent_)
86+
process(fixtures[index], (_, index, parent) => {
9487
assert.strictEqual(
95-
parent && index !== null && isLiteral(parent, index),
88+
parent && index !== undefined && isLiteral(parent, index),
9689
index === 0,
9790
String(index)
9891
)
@@ -115,10 +108,9 @@ test('isLiteral()', () => {
115108
let index = -1
116109

117110
while (++index < fixtures.length) {
118-
process(fixtures[index], (_, index, parent_) => {
119-
const parent = /** @type {Parent} */ (parent_)
111+
process(fixtures[index], (_, index, parent) => {
120112
assert.strictEqual(
121-
parent && index !== null && isLiteral(parent, index),
113+
parent && index !== undefined && isLiteral(parent, index),
122114
parent && index === parent.children.length - 2,
123115
String(index)
124116
)
@@ -158,8 +150,7 @@ test('isLiteral()', () => {
158150
let index = -1
159151

160152
while (++index < fixtures.length) {
161-
process(fixtures[index], (_, place, parent_) => {
162-
const parent = /** @type {Parent} */ (parent_)
153+
process(fixtures[index], (_, place, parent) => {
163154
let pos = 5
164155

165156
// Adjacent hyphens are part of the word.
@@ -173,7 +164,7 @@ test('isLiteral()', () => {
173164
}
174165

175166
assert.strictEqual(
176-
parent && place !== null && isLiteral(parent, place),
167+
parent && place !== undefined && isLiteral(parent, place),
177168
place === pos,
178169
String(index)
179170
)

0 commit comments

Comments
 (0)