Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Add all possible types for Plugin.use and Plugin.init
Browse files Browse the repository at this point in the history
  • Loading branch information
opl- committed Dec 3, 2019
1 parent 7136200 commit 9fdfdfb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ declare namespace Config {
class Plugins<Parent, PluginType extends Tapable.Plugin = webpack.Plugin> extends TypedChainedMap<Parent, Plugin<Parent, PluginType>> {}

class Plugin<Parent, PluginType extends Tapable.Plugin = webpack.Plugin> extends ChainedMap<Parent> implements Orderable {
init(value: (plugin: PluginClass<PluginType>, args: any[]) => PluginType): this;
use(plugin: PluginClass<PluginType>, args?: any[]): this;
init(value: (plugin: PluginType | PluginClass<PluginType>, args: any[]) => PluginType): this;
use(plugin: string | PluginType | PluginClass<PluginType>, args?: any[]): this;
tap(f: (args: any[]) => any[]): this;

// Orderable
Expand Down
10 changes: 10 additions & 0 deletions types/test/webpack-chain-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,20 @@ config
.after('bar')
.end()

.plugin('asString')
.use('package-name-or-path')
.end()

.plugin('asObject')
.use({ apply: (compiler: webpack.Compiler) => {}})
.end()

.plugins
.delete('foo')
.delete('bar')
.delete('baz')
.delete('asString')
.delete('asObject')
.end()

.node
Expand Down

0 comments on commit 9fdfdfb

Please sign in to comment.