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

Commit

Permalink
fix: fix type definition for Rule#oneOf (#218)
Browse files Browse the repository at this point in the history
Closes #216.
  • Loading branch information
loveky authored and edmorley committed Dec 19, 2019
1 parent 99da7c9 commit 7fb3c67
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
20 changes: 7 additions & 13 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ declare namespace Config {
packageMains: ChainedSet<this>
}

class Rule extends ChainedMap<Module> {
oneOfs: TypedChainedMap<this, OneOf>;
class Rule<T = Module> extends ChainedMap<T> implements Orderable {
oneOfs: TypedChainedMap<this, Rule<Rule>>;
uses: TypedChainedMap<this, Use>;
include: TypedChainedSet<this, webpack.Condition>;
exclude: TypedChainedSet<this, webpack.Condition>;
Expand All @@ -217,10 +217,13 @@ declare namespace Config {
type(value: 'javascript/auto' | 'javascript/dynamic' | 'javascript/esm' | 'json' | 'webassembly/experimental'): this;
enforce(value: 'pre' | 'post'): this;

use(name: string): Use;
oneOf(name: string): OneOf;
use(name: string): Use<this>;
oneOf(name: string): Rule<Rule>;
pre(): this;
post(): this;
before(name: string): this;
after(name: string): this;
resourceQuery(value: webpack.Condition | webpack.Condition[]): this;
}

class Optimization extends ChainedMap<Config> {
Expand Down Expand Up @@ -265,15 +268,6 @@ declare namespace Config {
after(name: string): this;
}

class OneOf extends ChainedMap<Rule> implements Orderable {
resourceQuery(value: webpack.Condition | webpack.Condition[]): this;
use(name: string): Use<this>;

// Orderable
before(name: string): this;
after(name: string): this;
}

type DevTool = 'eval' | 'inline-source-map' | 'cheap-eval-source-map' | 'cheap-source-map' |
'cheap-module-eval-source-map' | 'cheap-module-source-map' | 'eval-source-map' | 'source-map' |
'nosources-source-map' | 'hidden-source-map' | 'nosources-source-map' | '@eval' |
Expand Down
3 changes: 3 additions & 0 deletions types/test/webpack-chain-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ config
.post()
.oneOf('inline')
.after('vue')
.uses
.delete('babel')
.end()
.resourceQuery(/inline/)
.use('url')
.loader('url-loader')
Expand Down

0 comments on commit 7fb3c67

Please sign in to comment.