Skip to content

Commit 591b0c0

Browse files
committed
Fix types to support void async transformers
Related to #155.
1 parent 4919517 commit 591b0c0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ type Transformer = (
432432
node: Node,
433433
file: VFile,
434434
next: TransformCallback
435-
) => Promise<Node | undefined> | Node | Error | undefined | void
435+
) => Promise<Node | undefined | void> | Node | Error | undefined | void
436436

437437
/**
438438
* Callback you must call when a transformer is done.

test/async-function.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ test('async function transformer () {}', (t) => {
1010
t.plan(5)
1111

1212
unified()
13+
.use(() => {
14+
return async function () {}
15+
})
16+
.use(() => {
17+
return async function () {
18+
return undefined
19+
}
20+
})
1321
.use(() => {
1422
return async function (tree, file) {
1523
t.equal(tree, givenNode, 'passes correct tree to an async function')

0 commit comments

Comments
 (0)