(webpack): add missing possible 'entry' types (#19977)

* fix(webpack): add missing possible 'entry' types

resolves #19972

* style(webpack): fix spacing

* style(webpack): add parentheses

I've added parentheses around the return type of `EntryFunc` to clarify
the correct type is `() => (...types)` not `(() => string) | ...types`
This commit is contained in:
Ahmed T. Ali
2017-09-25 12:19:32 -07:00
committed by Mohamed Hegazy
parent 54cfc26a91
commit a82b876e9c
2 changed files with 24 additions and 1 deletions
+4 -1
View File
@@ -6,6 +6,7 @@
// Tommy Troy Lin <https://github.com/tommytroylin>
// Mohsen Azimi <https://github.com/mohsen1>
// Jonathan Creamer <https://github.com/jcreamer898>
// Ahmed T. Ali <https://github.com/ahmed-taj>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -36,7 +37,7 @@ declare namespace webpack {
* If `output.pathinfo` is set, the included pathinfo is shortened to this directory.
*/
context?: string;
entry?: string | string[] | Entry;
entry?: string | string[] | Entry | EntryFunc;
/** Choose a style of source mapping to enhance the debugging process. These values can affect build and rebuild speed dramatically. */
devtool?: Options.Devtool;
/** Options affecting the output. */
@@ -103,6 +104,8 @@ declare namespace webpack {
[name: string]: string | string[];
}
type EntryFunc = () => (string | string[] | Promise<string | string[]>);
interface DevtoolModuleFilenameTemplateInfo {
identifier: string;
shortIdentifier: string;
+20
View File
@@ -76,6 +76,26 @@ configuration = {
}
};
//
// https://webpack.js.org/configuration/entry-context/#dynamic-entry
//
configuration = {
entry: () => './demo'
};
configuration = {
entry: () => ['./demo', './demo2']
};
configuration = {
entry: () => new Promise((resolve) => resolve('./demo'))
};
configuration = {
entry: () => new Promise((resolve) => resolve(['./demo', './demo2']))
};
//
// https://webpack.github.io/docs/code-splitting.html
//