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

fix: fix type definition for Rule#oneOf #218

Merged
merged 1 commit into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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