88 * @typedef {import('../index.js').Parser } Parser
99 * @typedef {import('../index.js').Pluggable } Pluggable
1010 * @typedef {import('../index.js').PluggableList } PluggableList
11+ * @typedef {import('../index.js').PluginTuple } PluginTuple
1112 * @typedef {import('../index.js').Plugin } Plugin
1213 * @typedef {import('../index.js').Preset } Preset
1314 * @typedef {import('../index.js').ProcessCallback } ProcessCallback
1415 * @typedef {import('../index.js').Processor } Processor
1516 * @typedef {import('../index.js').RunCallback } RunCallback
16- * @typedef {import('../index.js').Transformer } Transformer
1717 */
1818
1919import structuredClone from '@ungap/structured-clone'
@@ -52,7 +52,6 @@ function base() {
5252
5353 // Plugins.
5454 processor . attachers = attachers
55- // @ts -expect-error: overloads are handled.
5655 processor . use = use
5756
5857 // API.
@@ -75,7 +74,8 @@ function base() {
7574 let index = - 1
7675
7776 while ( ++ index < attachers . length ) {
78- destination . use ( ...attachers [ index ] )
77+ const attacher = attachers [ index ]
78+ destination . use ( ...attacher )
7979 }
8080
8181 destination . data ( structuredClone ( namespace ) )
@@ -129,7 +129,6 @@ function base() {
129129 options [ 0 ] = undefined
130130 }
131131
132- /** @type {Transformer | void } */
133132 const transformer = attacher . call ( processor , ...options )
134133
135134 if ( typeof transformer === 'function' ) {
@@ -144,7 +143,7 @@ function base() {
144143 }
145144
146145 /**
147- * @param {Pluggable | null | undefined } [value]
146+ * @param {Exclude< Pluggable, PluginTuple> | PluggableList | null | undefined } [value]
148147 * @param {...unknown } options
149148 * @returns {Processor }
150149 */
@@ -176,15 +175,16 @@ function base() {
176175 return processor
177176
178177 /**
179- * @param {import('../index.js').Pluggable<Array<unknown>> } value
180- * @returns {void }
178+ * @param {import('../index.js').Pluggable } value
179+ * @returns {undefined }
181180 */
182181 function add ( value ) {
183182 if ( typeof value === 'function' ) {
184183 addPlugin ( value )
185184 } else if ( typeof value === 'object' ) {
186185 if ( Array . isArray ( value ) ) {
187- const [ plugin , ...options ] = value
186+ const [ plugin , ...options ] =
187+ /** @type {[Plugin, ...Array<unknown>] } */ ( value )
188188 addPlugin ( plugin , ...options )
189189 } else {
190190 addPreset ( value )
@@ -196,7 +196,7 @@ function base() {
196196
197197 /**
198198 * @param {Preset } result
199- * @returns {void }
199+ * @returns {undefined }
200200 */
201201 function addPreset ( result ) {
202202 if ( ! ( 'plugins' in result ) && ! ( 'settings' in result ) ) {
@@ -215,7 +215,7 @@ function base() {
215215
216216 /**
217217 * @param {PluggableList | null | undefined } [plugins]
218- * @returns {void }
218+ * @returns {undefined }
219219 */
220220 function addList ( plugins ) {
221221 let index = - 1
@@ -235,7 +235,7 @@ function base() {
235235 /**
236236 * @param {Plugin } plugin
237237 * @param {...unknown } [value]
238- * @returns {void }
238+ * @returns {undefined }
239239 */
240240 function addPlugin ( plugin , value ) {
241241 let index = - 1
@@ -299,7 +299,7 @@ function base() {
299299 * @param {Node } node
300300 * @param {RunCallback | VFileCompatible } [doc]
301301 * @param {RunCallback } [callback]
302- * @returns {Promise<Node> | void }
302+ * @returns {Promise<Node> | undefined }
303303 */
304304 function run ( node , doc , callback ) {
305305 assertNode ( node )
@@ -316,10 +316,11 @@ function base() {
316316
317317 executor ( undefined , callback )
318318
319+ // Note: `void`s needed for TS.
319320 /**
320- * @param {((node: Node) => void) | undefined } resolve
321- * @param {(error: Error) => void } reject
322- * @returns {void }
321+ * @param {((node: Node) => undefined | void) | undefined } resolve
322+ * @param {(error: Error) => undefined | void } reject
323+ * @returns {undefined }
323324 */
324325 function executor ( resolve , reject ) {
325326 // @ts -expect-error: `doc` can’t be a callback anymore, we checked.
@@ -329,7 +330,7 @@ function base() {
329330 * @param {Error | undefined } error
330331 * @param {Node } tree
331332 * @param {VFile } file
332- * @returns {void }
333+ * @returns {undefined }
333334 */
334335 function done ( error , tree , file ) {
335336 tree = tree || node
@@ -362,7 +363,7 @@ function base() {
362363 /**
363364 * @param {Error | undefined } [error]
364365 * @param {Node } [tree]
365- * @returns {void }
366+ * @returns {undefined }
366367 */
367368 function done ( error , tree ) {
368369 bail ( error )
@@ -387,10 +388,11 @@ function base() {
387388
388389 executor ( undefined , callback )
389390
391+ // Note: `void`s needed for TS.
390392 /**
391- * @param {((file: VFile) => void) | undefined } resolve
392- * @param {(error?: Error | undefined) => void } reject
393- * @returns {void }
393+ * @param {((file: VFile) => undefined | void) | undefined } resolve
394+ * @param {(error?: Error | undefined) => undefined | void } reject
395+ * @returns {undefined }
394396 */
395397 function executor ( resolve , reject ) {
396398 const file = vfile ( doc )
@@ -417,7 +419,7 @@ function base() {
417419 /**
418420 * @param {Error | undefined } [error]
419421 * @param {VFile | undefined } [file]
420- * @returns {void }
422+ * @returns {undefined }
421423 */
422424 function done ( error , file ) {
423425 if ( error || ! file ) {
@@ -432,7 +434,7 @@ function base() {
432434 }
433435 }
434436
435- /** @type {Processor['processSync'] } */
437+ /** @type {import('../index.js'). Processor['processSync'] } */
436438 function processSync ( doc ) {
437439 /** @type {boolean | undefined } */
438440 let complete
@@ -451,7 +453,7 @@ function base() {
451453
452454 /**
453455 * @param {Error | undefined } [error]
454- * @returns {void }
456+ * @returns {undefined }
455457 */
456458 function done ( error ) {
457459 complete = true
0 commit comments