1
1
/**
2
- * @typedef {import('unist').Node } Node
3
- * @typedef {import('unist-util-visit').Visitor<Node> } Visitor
2
+ * @typedef {import('unist').Parent } UnistParent
3
+ * @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').Visitor<Word> } Visitor
4
9
*/
5
10
6
11
import assert from 'node:assert'
@@ -53,7 +58,8 @@ test('isLiteral()', (t) => {
53
58
} , 'should not throw if `node` is in `parent`' )
54
59
55
60
t . doesNotThrow ( ( ) => {
56
- process ( 'Well? Ha! Funky' , ( _ , index , parent ) => {
61
+ process ( 'Well? Ha! Funky' , ( _ , index , parent_ ) => {
62
+ const parent = /** @type {Parent } */ ( parent_ )
57
63
assert . strictEqual (
58
64
parent && index !== null && isLiteral ( parent , index ) ,
59
65
false
@@ -76,7 +82,8 @@ test('isLiteral()', (t) => {
76
82
let index = - 1
77
83
78
84
while ( ++ index < fixtures . length ) {
79
- process ( fixtures [ index ] , ( _ , index , parent ) => {
85
+ process ( fixtures [ index ] , ( _ , index , parent_ ) => {
86
+ const parent = /** @type {Parent } */ ( parent_ )
80
87
assert . strictEqual (
81
88
parent && index !== null && isLiteral ( parent , index ) ,
82
89
index === 0 ,
@@ -101,7 +108,8 @@ test('isLiteral()', (t) => {
101
108
let index = - 1
102
109
103
110
while ( ++ index < fixtures . length ) {
104
- process ( fixtures [ index ] , ( _ , index , parent ) => {
111
+ process ( fixtures [ index ] , ( _ , index , parent_ ) => {
112
+ const parent = /** @type {Parent } */ ( parent_ )
105
113
assert . strictEqual (
106
114
parent && index !== null && isLiteral ( parent , index ) ,
107
115
parent && index === parent . children . length - 2 ,
@@ -143,7 +151,8 @@ test('isLiteral()', (t) => {
143
151
let index = - 1
144
152
145
153
while ( ++ index < fixtures . length ) {
146
- process ( fixtures [ index ] , ( _ , place , parent ) => {
154
+ process ( fixtures [ index ] , ( _ , place , parent_ ) => {
155
+ const parent = /** @type {Parent } */ ( parent_ )
147
156
let pos = 5
148
157
149
158
// Adjacent hyphens are part of the word.
0 commit comments