Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix next in types of transformer signature #149

Merged
merged 2 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,7 @@ export interface FrozenProcessor<P = Settings> {
* @typeParam P Processor settings
* @returns Optional Transformer.
*/
export type Plugin<
S extends any[] = [Settings?],
P = Settings
> = Attacher<S, P>
export type Plugin<S extends any[] = [Settings?], P = Settings> = Attacher<S, P>

/**
* Configuration passed to a Plugin or Processor
Expand Down Expand Up @@ -259,10 +256,10 @@ export interface ProcessorSettings<P = Settings> {
* @typeParam S Plugin settings
* @typeParam P Processor settings
*/
export type PluginTuple<
S extends any[] = [Settings?],
P = Settings
> = [Plugin<S, P>, ...S]
export type PluginTuple<S extends any[] = [Settings?], P = Settings> = [
Plugin<S, P>,
...S
]

/**
* A union of the different ways to add plugins to unified
Expand Down Expand Up @@ -316,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
6 changes: 3 additions & 3 deletions types/unified-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,19 @@ 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
Expand Down