Skip to content

Commit

Permalink
Fix types to support void async transformers
Browse files Browse the repository at this point in the history
Related to #155.
  • Loading branch information
wooorm committed Jul 21, 2021
1 parent 4919517 commit 591b0c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ type Transformer = (
node: Node,
file: VFile,
next: TransformCallback
) => Promise<Node | undefined> | Node | Error | undefined | void
) => Promise<Node | undefined | void> | Node | Error | undefined | void

/**
* Callback you must call when a transformer is done.
Expand Down
8 changes: 8 additions & 0 deletions test/async-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ test('async function transformer () {}', (t) => {
t.plan(5)

unified()
.use(() => {
return async function () {}
})
.use(() => {
return async function () {
return undefined
}
})
.use(() => {
return async function (tree, file) {
t.equal(tree, givenNode, 'passes correct tree to an async function')
Expand Down

0 comments on commit 591b0c0

Please sign in to comment.