Skip to content

Commit 678a0a0

Browse files
committed
Use @types/nlcst
1 parent f1253d5 commit 678a0a0

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
/**
2+
* @typedef {import('nlcst').Root} Root
3+
* @typedef {import('nlcst').Sentence} Sentence
4+
* @typedef {import('nlcst').Word} Word
5+
* @typedef {import('nlcst').Symbol} Symbol
6+
* @typedef {import('nlcst').Punctuation} Punctuation
7+
* @typedef {import('nlcst').SentenceContent} SentenceContent
8+
*
29
* @typedef Options
310
* Configuration.
411
* @property {boolean} [quotes=true]
@@ -33,14 +40,10 @@
3340
* When `'inverted'`, converts two dashes into an em-dash, and three dashes
3441
* into an en-dash.
3542
*
36-
* @typedef {import('unist').Node} Node
37-
* @typedef {import('unist').Parent} Parent
38-
* @typedef {import('unist').Literal<string>} Literal
39-
*
4043
* @callback Method
41-
* @param {Literal} node
44+
* @param {Punctuation|Symbol} node
4245
* @param {number} index
43-
* @param {Parent} parent
46+
* @param {Word|Sentence} parent
4447
* @returns {void}
4548
*/
4649

@@ -136,7 +139,7 @@ const educators = {
136139
}
137140

138141
// Search for dot-nodes with white-space between.
139-
/** @type {Node[]} */
142+
/** @type {SentenceContent[]} */
140143
const nodes = []
141144
let position = index
142145
let count = 1
@@ -158,7 +161,6 @@ const educators = {
158161
sibling &&
159162
(sibling.type === 'PunctuationNode' ||
160163
sibling.type === 'SymbolNode') &&
161-
// @ts-expect-error: it’s a literal.
162164
/^\.+$/.test(sibling.value)
163165
) {
164166
nodes.push(queue, sibling)
@@ -257,7 +259,7 @@ const educators = {
257259
* Plugin to replace dumb/straight/typewriter punctuation marks with smart/curly
258260
* punctuation marks.
259261
*
260-
* @type {import('unified').Plugin<[Options?]>}
262+
* @type {import('unified').Plugin<[Options?]|[], Root>}
261263
*/
262264
export default function retextSmartypants(options = {}) {
263265
/** @type {Array.<Method>} */

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"index.js"
3333
],
3434
"dependencies": {
35+
"@types/nlcst": "^1.0.0",
3536
"nlcst-to-string": "^3.0.0",
3637
"unified": "^10.0.0",
3738
"unist-util-visit": "^4.0.0"

0 commit comments

Comments
 (0)