1
1
/**
2
- * @typedef {import('unist').Parent } UnistParent
3
2
* @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
9
4
*/
10
5
11
6
import assert from 'node:assert/strict'
@@ -65,10 +60,9 @@ test('isLiteral()', () => {
65
60
} , 'should not throw if `node` is in `parent`' )
66
61
67
62
assert . doesNotThrow ( ( ) => {
68
- process ( 'Well? Ha! Funky' , ( _ , index , parent_ ) => {
69
- const parent = /** @type {Parent } */ ( parent_ )
63
+ process ( 'Well? Ha! Funky' , ( _ , index , parent ) => {
70
64
assert . strictEqual (
71
- parent && index !== null && isLiteral ( parent , index ) ,
65
+ parent && index !== undefined && isLiteral ( parent , index ) ,
72
66
false
73
67
)
74
68
} )
@@ -89,10 +83,9 @@ test('isLiteral()', () => {
89
83
let index = - 1
90
84
91
85
while ( ++ index < fixtures . length ) {
92
- process ( fixtures [ index ] , ( _ , index , parent_ ) => {
93
- const parent = /** @type {Parent } */ ( parent_ )
86
+ process ( fixtures [ index ] , ( _ , index , parent ) => {
94
87
assert . strictEqual (
95
- parent && index !== null && isLiteral ( parent , index ) ,
88
+ parent && index !== undefined && isLiteral ( parent , index ) ,
96
89
index === 0 ,
97
90
String ( index )
98
91
)
@@ -115,10 +108,9 @@ test('isLiteral()', () => {
115
108
let index = - 1
116
109
117
110
while ( ++ index < fixtures . length ) {
118
- process ( fixtures [ index ] , ( _ , index , parent_ ) => {
119
- const parent = /** @type {Parent } */ ( parent_ )
111
+ process ( fixtures [ index ] , ( _ , index , parent ) => {
120
112
assert . strictEqual (
121
- parent && index !== null && isLiteral ( parent , index ) ,
113
+ parent && index !== undefined && isLiteral ( parent , index ) ,
122
114
parent && index === parent . children . length - 2 ,
123
115
String ( index )
124
116
)
@@ -158,8 +150,7 @@ test('isLiteral()', () => {
158
150
let index = - 1
159
151
160
152
while ( ++ index < fixtures . length ) {
161
- process ( fixtures [ index ] , ( _ , place , parent_ ) => {
162
- const parent = /** @type {Parent } */ ( parent_ )
153
+ process ( fixtures [ index ] , ( _ , place , parent ) => {
163
154
let pos = 5
164
155
165
156
// Adjacent hyphens are part of the word.
@@ -173,7 +164,7 @@ test('isLiteral()', () => {
173
164
}
174
165
175
166
assert . strictEqual (
176
- parent && place !== null && isLiteral ( parent , place ) ,
167
+ parent && place !== undefined && isLiteral ( parent , place ) ,
177
168
place === pos ,
178
169
String ( index )
179
170
)
0 commit comments