diff --git a/types/index.d.ts b/types/index.d.ts index 19b94492..5b971703 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -17,7 +17,7 @@ export interface Processor

extends FrozenProcessor

{ * @typeParam S Plugin settings * @returns The processor on which use is called */ - use( + use( plugin: Plugin, ...settings: S ): Processor

@@ -221,7 +221,10 @@ export interface FrozenProcessor

{ * @typeParam P Processor settings * @returns Optional Transformer. */ -export type Plugin = Attacher +export type Plugin< + S extends any[] = [(Settings | boolean)?], + P = Settings +> = Attacher /** * Configuration passed to a Plugin or Processor @@ -256,10 +259,10 @@ export interface ProcessorSettings

{ * @typeParam S Plugin settings * @typeParam P Processor settings */ -export type PluginTuple = [ - Plugin, - ...S -] +export type PluginTuple< + S extends any[] = [(Settings | boolean)?], + P = Settings +> = [Plugin, ...S] /** * A union of the different ways to add plugins to unified diff --git a/types/unified-tests.ts b/types/unified-tests.ts index 66829299..89652f0d 100644 --- a/types/unified-tests.ts +++ b/types/unified-tests.ts @@ -77,6 +77,12 @@ processor.use([ [plugin, settings], [plugin, settings] ]) +processor.use(plugin, true) +processor.use(plugin, false) +processor.use([ + [plugin, true], + [plugin, false] +]) processor.use(parserPlugin) processor.use(parserPlugin).use(parserPlugin)