Skip to content

Commit

Permalink
Fix next in types of transformer signature
Browse files Browse the repository at this point in the history
Closes GH-149.

Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
  • Loading branch information
wooorm authored Jul 6, 2021
1 parent 6ef3933 commit 350ed9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 1 addition & 5 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,7 @@ export type Attacher<S extends any[] = [Settings?], P = Settings> = (
export type Transformer = (
node: Node,
file: VFile,
next: (
error: Error | null,
tree?: Node,
file?: VFile
) => Record<string, unknown>
next: (error?: Error | null, tree?: Node, file?: VFile) => void
) => Error | Node | Promise<Node> | void | Promise<void>

/**
Expand Down
9 changes: 6 additions & 3 deletions types/unified-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,27 @@ processor.use(
(
tree: Node,
file: VFile,
next: (error: Error | null, tree: Node, file: VFile) => {}
next: (error: Error | null, tree: Node, file: VFile) => void
) => {}
)
processor.use(
() =>
(
tree: Node,
file: VFile,
next: (error: Error | null, tree: Node) => {}
next: (error: Error | null, tree: Node) => void
) => {}
)
processor.use(
() => (tree: Node, file: VFile, next: (error: Error | null) => {}) => {}
() => (tree: Node, file: VFile, next: (error: Error | null) => void) => {}
)
processor.use(
// $ExpectError
() => (tree: Node, file: VFile, next: () => {}) => {}
)
processor.use(() => (tree: Node, file: VFile, next: () => void) => {
next()
})

processor.use(pluginWithTwoSettings)
processor.use(pluginWithTwoSettings).use(pluginWithTwoSettings)
Expand Down

0 comments on commit 350ed9d

Please sign in to comment.