Skip to content

Commit fda888e

Browse files
committed
Use @types/nlcst
1 parent 19315c8 commit fda888e

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/**
2-
* @typedef {import('unist').Node} Node
3-
* @typedef {import('unist').Parent} Parent
2+
* @typedef {import('unist').Parent} UnistParent
3+
* @typedef {import('nlcst').Root} Root
4+
* @typedef {import('nlcst').Content} Content
5+
* @typedef {Root|Content} Node
6+
* @typedef {Extract<Node, UnistParent>} Parent
47
*/
58

69
import {toString} from 'nlcst-to-string'

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"index.js"
3232
],
3333
"dependencies": {
34+
"@types/nlcst": "^1.0.0",
3435
"@types/unist": "^2.0.0",
3536
"nlcst-to-string": "^3.0.0"
3637
},

test.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
/**
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
49
*/
510

611
import assert from 'node:assert'
@@ -53,7 +58,8 @@ test('isLiteral()', (t) => {
5358
}, 'should not throw if `node` is in `parent`')
5459

5560
t.doesNotThrow(() => {
56-
process('Well? Ha! Funky', (_, index, parent) => {
61+
process('Well? Ha! Funky', (_, index, parent_) => {
62+
const parent = /** @type {Parent} */ (parent_)
5763
assert.strictEqual(
5864
parent && index !== null && isLiteral(parent, index),
5965
false
@@ -76,7 +82,8 @@ test('isLiteral()', (t) => {
7682
let index = -1
7783

7884
while (++index < fixtures.length) {
79-
process(fixtures[index], (_, index, parent) => {
85+
process(fixtures[index], (_, index, parent_) => {
86+
const parent = /** @type {Parent} */ (parent_)
8087
assert.strictEqual(
8188
parent && index !== null && isLiteral(parent, index),
8289
index === 0,
@@ -101,7 +108,8 @@ test('isLiteral()', (t) => {
101108
let index = -1
102109

103110
while (++index < fixtures.length) {
104-
process(fixtures[index], (_, index, parent) => {
111+
process(fixtures[index], (_, index, parent_) => {
112+
const parent = /** @type {Parent} */ (parent_)
105113
assert.strictEqual(
106114
parent && index !== null && isLiteral(parent, index),
107115
parent && index === parent.children.length - 2,
@@ -143,7 +151,8 @@ test('isLiteral()', (t) => {
143151
let index = -1
144152

145153
while (++index < fixtures.length) {
146-
process(fixtures[index], (_, place, parent) => {
154+
process(fixtures[index], (_, place, parent_) => {
155+
const parent = /** @type {Parent} */ (parent_)
147156
let pos = 5
148157

149158
// Adjacent hyphens are part of the word.

0 commit comments

Comments
 (0)