diff --git a/types/webpack-chain/index.d.ts b/types/webpack-chain/index.d.ts index 4a13f91530..68839d423c 100644 --- a/types/webpack-chain/index.d.ts +++ b/types/webpack-chain/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webpack-chain 3.0 +// Type definitions for webpack-chain 4.0 // Project: https://github.com/mozilla-neutrino/webpack-chain // Definitions by: Eirikur Nilsson , Paul Sachs // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,9 +8,42 @@ import * as https from 'https'; export = Config; -declare class Config { +declare namespace __Config { + class Chained { + end(): Parent; + } + + class TypedChainedMap extends Chained { + clear(): this; + delete(key: string): this; + has(key: string): boolean; + get(key: string): Value; + set(key: string, value: Value): this; + merge(obj: { [key: string]: Value }): this; + entries(): { [key: string]: Value }; + values(): Value[]; + when(condition: boolean, trueBrancher: (obj: any) => void, falseBrancher?: (obj: any) => void): this; + } + + class ChainedMap extends TypedChainedMap {} + + class TypedChainedSet extends Chained { + add(value: Value): this; + prepend(value: Value): this; + clear(): this; + delete(key: string): this; + has(key: string): boolean; + merge(arr: Value[]): this; + values(): Value[]; + when(condition: boolean, trueBrancher: (obj: any) => void, falseBrancher?: (obj: any) => void): this; + } + + class ChainedSet extends TypedChainedSet {} +} + +declare class Config extends __Config.ChainedMap { devServer: Config.DevServer; - entryPoints: Config.EntryPoints; + entryPoints: Config.TypedChainedMap; module: Config.Module; node: Config.ChainedMap; output: Config.Output; @@ -35,42 +68,18 @@ declare class Config { watch(value: boolean): this; watchOptions(value: webpack.Options.WatchOptions): this; - entry(name: string): Config.ChainedSet; + entry(name: string): Config.EntryPoint; plugin(name: string): Config.Plugin; toConfig(): webpack.Configuration; - merge(obj: any): this; } declare namespace Config { - class Chained { - end(): Parent; - } - - class TypedChainedMap extends Chained { - clear(): this; - delete(key: string): this; - has(key: string): boolean; - get(key: string): Value; - set(key: string, value: Value): this; - merge(obj: { [key: string]: Value }): this; - entries(): { [key: string]: Value }; - values(): Value[]; - } - - class ChainedMap extends TypedChainedMap {} - - class TypedChainedSet extends Chained { - add(value: Value): this; - prepend(value: Value): this; - clear(): this; - delete(key: string): this; - has(key: string): boolean; - merge(arr: Value[]): this; - values(): Value[]; - } - - class ChainedSet extends TypedChainedSet {} + class Chained extends __Config.Chained {} + class TypedChainedMap extends __Config.TypedChainedMap {} + class ChainedMap extends __Config.TypedChainedMap {} + class TypedChainedSet extends __Config.TypedChainedSet {} + class ChainedSet extends __Config.TypedChainedSet {} class Plugins extends TypedChainedMap> {} @@ -128,11 +137,16 @@ declare namespace Config { noInfo(value: boolean): this; overlay(value: boolean | { warnings?: boolean, errors?: boolean }): this; port(value: number): this; + progress(value: boolean): this; proxy(value: any): this; + public(value: string): this; + publicPath(publicPath: string): this; quiet(value: boolean): this; setup(value: (expressApp: any) => void): this; + staticOptions(value: any): this; stats(value: webpack.Options.Stats): this; watchContentBase(value: boolean): this; + watchOptions(value: any): this; } class Performance extends ChainedMap { @@ -142,7 +156,7 @@ declare namespace Config { assetFilter(value: (assetFilename: string) => boolean): this; } - class EntryPoints extends TypedChainedMap> {} + class EntryPoint extends TypedChainedSet {} class Resolve extends ChainedMap { alias: TypedChainedMap; diff --git a/types/webpack-chain/webpack-chain-tests.ts b/types/webpack-chain/webpack-chain-tests.ts index 1118fe0d26..07593687cf 100644 --- a/types/webpack-chain/webpack-chain-tests.ts +++ b/types/webpack-chain/webpack-chain-tests.ts @@ -29,11 +29,13 @@ config .target('web') .watch(true) .watchOptions({}) + .when(false, config => config.watch(true), config => config.watch(false)) .entry('main') .add('index.js') .delete('index.js') .clear() + .when(false, entry => entry.clear(), entry => entry.clear()) .end() .entryPoints @@ -71,15 +73,20 @@ config errors: true, }) .port(8080) + .progress(true) .proxy({}) + .public('foo') + .publicPath('bar') .quiet(false) .setup(app => {}) + .staticOptions({}) .stats({ reasons: true, errors: true, warnings: false, }) .watchContentBase(true) + .watchOptions({}) .end() .module