refactor: improve eslint configuration and better types

This commit is contained in:
alexander-akait 2025-03-12 04:56:14 +03:00
parent 1178013c99
commit a1df00d339
141 changed files with 930 additions and 782 deletions

1
declarations.d.ts vendored
View File

@ -408,6 +408,7 @@ interface ImportAttributeNode {
type TODO = any;
type EXPECTED_ANY = any;
type EXPECTED_OBJECT = object;
type RecursiveArrayOrRecord<T> =
| { [index: string]: RecursiveArrayOrRecord<T> }

View File

@ -97,11 +97,8 @@ export default [
"no-else-return": "error",
"no-lonely-if": "error",
"no-undef-init": "error",
// Disallow @ts-ignore directive. Use @ts-expect-error instead
"no-warning-comments": [
"error",
{ terms: ["@ts-ignore"], location: "start" }
],
// Disallow ts-ignore directive. Use ts-expect-error instead
"no-warning-comments": ["error", { terms: ["@ts-ignore"] }],
"no-constructor-return": "error",
"symbol-description": "error",
"array-callback-return": [
@ -282,15 +279,12 @@ export default [
mode: "typescript",
// supported tags https://github.com/microsoft/TypeScript-wiki/blob/master/JSDoc-support-in-JavaScript.md
tagNamePreference: {
...["implements", "const", "memberof", "yields"].reduce(
(acc, tag) => {
acc[tag] = {
message: `@${tag} currently not supported in TypeScript`
};
return acc;
},
{}
),
...["memberof", "yields", "member"].reduce((acc, tag) => {
acc[tag] = {
message: `@${tag} currently not supported in TypeScript`
};
return acc;
}, {}),
extends: "extends",
return: "returns",
constructor: "constructor",
@ -308,8 +302,7 @@ export default [
rules: {
...jsdocConfig.rules,
// Override recommended
// TODO remove me after switch to typescript strict mode
"jsdoc/require-jsdoc": "off",
//
// Doesn't support function overloading/tuples/`readonly`/module keyword/etc
// Also `typescript` reports this itself
"jsdoc/valid-types": "off",
@ -320,12 +313,36 @@ export default [
// More rules
"jsdoc/check-indentation": "error",
"jsdoc/no-bad-blocks": "error",
"jsdoc/check-line-alignment": ["error", "never"],
"jsdoc/require-asterisk-prefix": "error",
"jsdoc/require-hyphen-before-param-description": ["error", "never"],
"jsdoc/require-template": "error",
"jsdoc/no-bad-blocks": "error",
"jsdoc/no-blank-block-descriptions": "error",
"jsdoc/no-blank-blocks": "error",
"jsdoc/require-asterisk-prefix": "error"
"jsdoc/no-restricted-syntax": [
"error",
{
contexts: [
// No `@type {*}`
{
comment: "JsdocBlock:has(JsdocTypeAny)",
message: "Please use `any`."
},
// No `@type {?}`
{
comment: "JsdocBlock:has(JsdocTypeUnknown)",
message: "Please use `unknown` or `any`"
},
// Prefer TypeScript syntax for functions
{
comment: "JsdocBlock:has(JsdocTypeFunction[arrow=false])",
message:
"Please use TypeScript syntax - `(a: string, b: boolean) => number`"
}
]
}
]
}
},
{
@ -363,7 +380,8 @@ export default [
"func-style": "off",
"unicorn/prefer-includes": "off",
"unicorn/no-useless-undefined": "off",
"unicorn/no-array-for-each": "off"
"unicorn/no-array-for-each": "off",
"jsdoc/require-jsdoc": "off"
}
},
{
@ -398,16 +416,17 @@ export default [
"jest/no-done-callback": "off",
"jest/expect-expect": "off",
"jest/no-conditional-expect": "off",
"object-shorthand": "off",
camelcase: "off",
"no-var": "off",
"jsdoc/require-jsdoc": "off",
"n/no-unsupported-features/node-builtins": [
"error",
{
ignores: ["Blob"],
allowExperimental: true
}
],
"object-shorthand": "off",
camelcase: "off",
"no-var": "off"
]
}
},
{

View File

@ -19,7 +19,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
const validate = createSchemaValidation(
/** @type {(function(typeof import("../schemas/plugins/BannerPlugin.json")): boolean)} */
/** @type {((value: typeof import("../schemas/plugins/BannerPlugin.json")) => boolean)} */
(require("../schemas/plugins/BannerPlugin.check.js")),
() => require("../schemas/plugins/BannerPlugin.json"),
{

View File

@ -15,7 +15,7 @@ const {
/**
* @typedef {object} Etag
* @property {function(): string} toString
* @property {() => string} toString
*/
/**
@ -29,14 +29,14 @@ const {
/**
* @callback GotHandler
* @param {any} result
* @param {function(Error=): void} callback
* @param {(err?: Error) => void} callback
* @returns {void}
*/
/**
* @param {number} times times
* @param {function(Error=): void} callback callback
* @returns {function(Error=): void} callback
* @param {(err?: Error) => void} callback callback
* @returns {(err?: Error) => void} callback
*/
const needCalls = (times, callback) => err => {
if (--times === 0) {

View File

@ -160,7 +160,7 @@ class ItemCacheFacade {
/**
* @template T
* @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
* @param {(callback: CallbackNormalErrorCache<T>) => void} computer function to compute the value if not cached
* @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
* @returns {void}
*/
@ -180,7 +180,7 @@ class ItemCacheFacade {
/**
* @template T
* @param {function(): Promise<T> | T} computer function to compute the value if not cached
* @param {() => Promise<T> | T} computer function to compute the value if not cached
* @returns {Promise<T>} promise with the data
*/
async providePromise(computer) {
@ -310,7 +310,7 @@ class CacheFacade {
* @template T
* @param {string} identifier the cache identifier
* @param {Etag | null} etag the etag
* @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
* @param {(callback: CallbackNormalErrorCache<T>) => void} computer function to compute the value if not cached
* @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
* @returns {void}
*/
@ -332,7 +332,7 @@ class CacheFacade {
* @template T
* @param {string} identifier the cache identifier
* @param {Etag | null} etag the etag
* @param {function(): Promise<T> | T} computer function to compute the value if not cached
* @param {() => Promise<T> | T} computer function to compute the value if not cached
* @returns {Promise<T>} promise with the data
*/
async providePromise(identifier, etag, computer) {

View File

@ -61,7 +61,7 @@ const compareModuleIterables = compareIterables(compareModulesByIdentifier);
class ModuleHashInfo {
/**
* @param {string} hash hash
* @param {string} renderedHash rendered hash
* @param {string} renderedHash rendered hash
*/
constructor(hash, renderedHash) {
this.hash = hash;
@ -92,7 +92,7 @@ const getModuleRuntimes = chunks => {
/**
* @param {WeakMap<Module, Set<string>> | undefined} sourceTypesByModule sourceTypesByModule
* @returns {function (SortableSet<Module>): Map<string, SortableSet<Module>>} modules by source type
* @returns {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} modules by source type
*/
const modulesBySourceType = sourceTypesByModule => set => {
/** @type {Map<string, SortableSet<Module>>} */
@ -129,7 +129,7 @@ const createOrderedArrayFunctionMap = new WeakMap();
/**
* @template T
* @param {function(T, T): -1|0|1} comparator comparator function
* @param {(a: T, b:T) => -1 | 0 | 1 } comparator comparator function
* @returns {SetToArrayFunction<T>} set as ordered array
*/
const createOrderedArrayFunction = comparator => {
@ -237,6 +237,8 @@ class ChunkGraphChunk {
}
}
/** @typedef {(a: Module, b: Module) => -1 | 0 | 1} ModuleComparator */
class ChunkGraph {
/**
* @param {ModuleGraph} moduleGraph the module graph
@ -535,7 +537,7 @@ class ChunkGraph {
/**
* @param {Module} module the module
* @param {function(Chunk, Chunk): -1|0|1} sortFn sort function
* @param {(a: Chunk, b: Chunk) => -1 | 0 | 1} sortFn sort function
* @returns {Iterable<Chunk>} iterable of chunks (do not modify)
*/
getOrderedModuleChunksIterable(module, sortFn) {
@ -686,7 +688,7 @@ class ChunkGraph {
/**
* @param {Chunk} chunk the chunk
* @param {function(Module, Module): -1|0|1} comparator comparator function
* @param {ModuleComparator} comparator comparator function
* @returns {Iterable<Module>} return the modules for this chunk
*/
getOrderedChunkModulesIterable(chunk, comparator) {
@ -698,7 +700,7 @@ class ChunkGraph {
/**
* @param {Chunk} chunk the chunk
* @param {string} sourceType source type
* @param {function(Module, Module): -1|0|1} comparator comparator function
* @param {ModuleComparator} comparator comparator function
* @returns {Iterable<Module> | undefined} return the modules for this chunk
*/
getOrderedChunkModulesIterableBySourceType(chunk, sourceType, comparator) {
@ -722,7 +724,7 @@ class ChunkGraph {
/**
* @param {Chunk} chunk the chunk
* @param {function(Module, Module): -1|0|1} comparator comparator function
* @param {ModuleComparator} comparator comparator function
* @returns {Module[]} return the modules for this chunk (cached, do not modify)
*/
getOrderedChunkModules(chunk, comparator) {

View File

@ -42,7 +42,7 @@ class ChunkTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(RenderManifestEntry[], RenderManifestOptions): RenderManifestEntry[]} fn function
* @param {(renderManifestEntries: RenderManifestEntry[], renderManifestOptions: RenderManifestOptions) => RenderManifestEntry[]} fn function
*/
(options, fn) => {
compilation.hooks.renderManifest.tap(
@ -62,7 +62,7 @@ class ChunkTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Source, ModuleTemplate, RenderContext): Source} fn function
* @param {(source: Source, moduleTemplate: ModuleTemplate, renderContext: RenderContext) => Source} fn function
*/
(options, fn) => {
getJavascriptModulesPlugin()
@ -84,7 +84,7 @@ class ChunkTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Source, ModuleTemplate, RenderContext): Source} fn function
* @param {(source: Source, moduleTemplate: ModuleTemplate, renderContext: RenderContext) => Source} fn function
*/
(options, fn) => {
getJavascriptModulesPlugin()
@ -106,7 +106,7 @@ class ChunkTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Source, Chunk): Source} fn function
* @param {(source: Source, chunk: Chunk) => Source} fn function
*/
(options, fn) => {
getJavascriptModulesPlugin()
@ -132,7 +132,7 @@ class ChunkTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Hash): void} fn function
* @param {(hash: Hash) => void} fn function
*/
(options, fn) => {
compilation.hooks.fullHash.tap(options, fn);
@ -146,7 +146,7 @@ class ChunkTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Hash, Chunk, ChunkHashContext): void} fn function
* @param {(hash: Hash, chunk: Chunk, chunkHashContext: ChunkHashContext) => void} fn function
*/
(options, fn) => {
getJavascriptModulesPlugin()

View File

@ -19,9 +19,7 @@ const processAsyncTree = require("./util/processAsyncTree");
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
/** @typedef {import("./util/fs").StatsCallback} StatsCallback */
/** @typedef {(function(string):boolean)|RegExp} IgnoreItem */
/** @typedef {Map<string, number>} Assets */
/** @typedef {function(IgnoreItem): void} AddToIgnoreCallback */
/**
* @typedef {object} CleanPluginCompilationHooks
@ -63,11 +61,13 @@ const mergeAssets = (as1, as2) => {
}
};
/** @typedef {Set<string>} Diff */
/**
* @param {OutputFileSystem} fs filesystem
* @param {string} outputPath output path
* @param {Map<string, number>} currentAssets filename of the current assets (must not start with .. or ., must only use / as path separator)
* @param {function((Error | null)=, Set<string>=): void} callback returns the filenames of the assets that shouldn't be there
* @param {(err?: Error | null, set?: Diff) => void} callback returns the filenames of the assets that shouldn't be there
* @returns {void}
*/
const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
@ -116,7 +116,7 @@ const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
/**
* @param {Assets} currentAssets assets list
* @param {Assets} oldAssets old assets list
* @returns {Set<string>} diff
* @returns {Diff} diff
*/
const getDiffToOldAssets = (currentAssets, oldAssets) => {
const diff = new Set();
@ -148,9 +148,9 @@ const doStat = (fs, filename, callback) => {
* @param {string} outputPath output path
* @param {boolean} dry only log instead of fs modification
* @param {Logger} logger logger
* @param {Set<string>} diff filenames of the assets that shouldn't be there
* @param {function(string): boolean | void} isKept check if the entry is ignored
* @param {function(Error=, Assets=): void} callback callback
* @param {Diff} diff filenames of the assets that shouldn't be there
* @param {(path: string) => boolean | void} isKept check if the entry is ignored
* @param {(err?: Error, assets?: Assets) => void} callback callback
* @returns {void}
*/
const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
@ -402,7 +402,7 @@ class CleanPlugin {
/**
* @param {(Error | null)=} err err
* @param {Set<string>=} diff diff
* @param {Diff=} diff diff
*/
const diffCallback = (err, diff) => {
if (err) {
@ -415,7 +415,7 @@ class CleanPlugin {
outputPath,
dry,
logger,
/** @type {Set<string>} */ (diff),
/** @type {Diff} */ (diff),
isKept,
(err, keptAssets) => {
if (err) {

View File

@ -193,10 +193,10 @@ const { isSourceEqual } = require("./util/source");
/**
* @typedef {object} ChunkPathData
* @property {string|number} id
* @property {string | number} id
* @property {string=} name
* @property {string} hash
* @property {function(number): string=} hashWithLength
* @property {((length: number) => string)=} hashWithLength
* @property {(Record<string, string>)=} contentHash
* @property {(Record<string, (length: number) => string>)=} contentHashWithLength
*/
@ -310,25 +310,25 @@ const { isSourceEqual } = require("./util/source");
/**
* @typedef {object} ModulePathData
* @property {string|number} id
* @property {string | number} id
* @property {string} hash
* @property {function(number): string=} hashWithLength
* @property {((length: number) => string)=} hashWithLength
*/
/**
* @typedef {object} PathData
* @property {ChunkGraph=} chunkGraph
* @property {string=} hash
* @property {function(number): string=} hashWithLength
* @property {(Chunk|ChunkPathData)=} chunk
* @property {(Module|ModulePathData)=} module
* @property {((length: number) => string)=} hashWithLength
* @property {(Chunk | ChunkPathData)=} chunk
* @property {(Module | ModulePathData)=} module
* @property {RuntimeSpec=} runtime
* @property {string=} filename
* @property {string=} basename
* @property {string=} query
* @property {string=} contentHashType
* @property {string=} contentHash
* @property {function(number): string=} contentHashWithLength
* @property {((length: number) => string)=} contentHashWithLength
* @property {boolean=} noChunkHash
* @property {string=} url
*/
@ -644,7 +644,7 @@ class Compilation {
* @template T
* @param {string} name name of the hook
* @param {number} stage new stage
* @param {function(): AsArray<T>} getArgs get old hook function args
* @param {() => AsArray<T>} getArgs get old hook function args
* @param {string=} code deprecation code (not deprecated when unset)
* @returns {FakeHook<Pick<AsyncSeriesHook<T>, "tap" | "tapAsync" | "tapPromise" | "name">>} fake hook which redirects
*/
@ -936,7 +936,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
/** @type {SyncHook<[Chunk, string]>} */
chunkAsset: new SyncHook(["chunk", "filename"]),
/** @type {SyncWaterfallHook<[string, object, AssetInfo | undefined]>} */
/** @type {SyncWaterfallHook<[string, PathData, AssetInfo | undefined]>} */
assetPath: new SyncWaterfallHook(["path", "options", "assetInfo"]),
/** @type {SyncBailHook<[], boolean | void>} */
@ -1255,7 +1255,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
}
/**
* @param {string | (function(): string)} name name of the logger, or function called once to get the logger name
* @param {string | (() => string)} name name of the logger, or function called once to get the logger name
* @returns {Logger} a logger with that name
*/
getLogger(name) {
@ -3565,7 +3565,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
* @param {RuntimeTemplate} runtimeTemplate runtimeTemplate
* @param {WebpackError[]} errors errors
* @param {CodeGenerationResults} results results
* @param {function((WebpackError | null)=, boolean=): void} callback callback
* @param {(err?: WebpackError | null, result?: boolean) => void} callback callback
*/
_codeGenerationModule(
module,
@ -4651,8 +4651,8 @@ This prevents using hashes of each other and should be avoided.`);
/**
* @param {string} file file name
* @param {Source | function(Source): Source} newSourceOrFunction new asset source or function converting old to new
* @param {(AssetInfo | function(AssetInfo | undefined): AssetInfo) | undefined} assetInfoUpdateOrFunction new asset info or function converting old to new
* @param {Source | ((source: Source) => Source)} newSourceOrFunction new asset source or function converting old to new
* @param {(AssetInfo | ((assetInfo?: AssetInfo) => AssetInfo)) | undefined} assetInfoUpdateOrFunction new asset info or function converting old to new
*/
updateAsset(
file,

View File

@ -341,7 +341,7 @@ class Compiler {
}
/**
* @param {string | (function(): string)} name name of the logger, or function called once to get the logger name
* @param {string | (() => string)} name name of the logger, or function called once to get the logger name
* @returns {Logger} a logger with that name
*/
getInfrastructureLogger(name) {

View File

@ -39,11 +39,13 @@ const makeSerializable = require("./util/makeSerializable");
/** @typedef {import("./Dependency")} Dependency */
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
/** @typedef {import("./Module").BuildCallback} BuildCallback */
/** @typedef {import("./Module").BuildInfo} BuildInfo */
/** @typedef {import("./Module").BuildMeta} BuildMeta */
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("./ModuleGraph")} ModuleGraph */
/** @typedef {import("./RequestShortener")} RequestShortener */
@ -399,7 +401,7 @@ class ContextModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild({ fileSystemInfo }, callback) {
@ -422,7 +424,7 @@ class ContextModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -19,7 +19,7 @@ const { join } = require("./util/fs");
/** @typedef {import("./ContextModule").ResolveDependenciesCallback} ResolveDependenciesCallback */
/** @typedef {import("./Module")} Module */
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
/** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("./ResolverFactory")} ResolverFactory */
/** @typedef {import("./dependencies/ContextDependency")} ContextDependency */
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
@ -86,7 +86,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create(data, callback) {
@ -335,7 +335,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
/**
* @param {string} ctx context
* @param {string} directory directory
* @param {function(string, string, function(): void): void} addSubDirectory addSubDirectoryFn
* @param {(context: string, subResource: string, callback: () => void) => void} addSubDirectory addSubDirectoryFn
* @param {ResolveDependenciesCallback} callback callback
*/
const addDirectory = (ctx, directory, addSubDirectory, callback) => {

View File

@ -33,7 +33,7 @@ const createHash = require("./util/createHash");
/** @typedef {import("./logging/Logger").Logger} Logger */
/** @typedef {import("./util/createHash").Algorithm} Algorithm */
/** @typedef {null|undefined|RegExp|Function|string|number|boolean|bigint|undefined} CodeValuePrimitive */
/** @typedef {null | undefined | RegExp | Function | string | number | boolean | bigint | undefined} CodeValuePrimitive */
/** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive|RuntimeValue>} CodeValue */
/**
@ -42,11 +42,11 @@ const createHash = require("./util/createHash");
* @property {string[]=} contextDependencies
* @property {string[]=} missingDependencies
* @property {string[]=} buildDependencies
* @property {string|function(): string=} version
* @property {string| (() => string)=} version
*/
/** @typedef {string | Set<string>} ValueCacheVersion */
/** @typedef {function({ module: NormalModule, key: string, readonly version: ValueCacheVersion }): CodeValuePrimitive} GeneratorFn */
/** @typedef {(value: { module: NormalModule, key: string, readonly version: ValueCacheVersion }) => CodeValuePrimitive} GeneratorFn */
class RuntimeValue {
/**
@ -137,7 +137,7 @@ function getObjKeys(properties) {
/** @typedef {boolean | undefined | null} AsiSafe */
/**
* @param {any[]|{[k: string]: any}} obj obj
* @param {any[] | {[k: string]: any}} obj obj
* @param {JavascriptParser} parser Parser
* @param {ValueCacheVersions} valueCacheVersions valueCacheVersions
* @param {string} key the defined key
@ -411,7 +411,7 @@ class DefinePlugin {
* @template {Function} T
* @param {string} key key
* @param {T} fn fn
* @returns {function(TODO): TODO} result
* @returns {(expression: Expression) => TODO} result
*/
const withValueDependency =
(key, fn) =>

View File

@ -22,9 +22,11 @@ const makeSerializable = require("./util/makeSerializable");
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
/** @typedef {import("./LibManifestPlugin").ManifestModuleData} ManifestModuleData */
/** @typedef {import("./Module").BuildCallback} BuildCallback */
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("./Module").SourceContext} SourceContext */
/** @typedef {import("./RequestShortener")} RequestShortener */
@ -106,7 +108,7 @@ class DelegatedModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -118,7 +120,7 @@ class DelegatedModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -81,7 +81,7 @@ const memoize = require("./util/memoize");
* @property {boolean=} canMangle when false, referenced export can not be mangled, defaults to true
*/
/** @typedef {function(ModuleGraphConnection, RuntimeSpec): ConnectionState} GetConditionFn */
/** @typedef {(moduleGraphConnection: ModuleGraphConnection, runtime: RuntimeSpec) => ConnectionState} GetConditionFn */
const TRANSITIVE = Symbol("transitive");
@ -328,8 +328,8 @@ Dependency.NO_EXPORTS_REFERENCED = [];
/** @type {string[][]} */
Dependency.EXPORTS_OBJECT_REFERENCED = [[]];
// eslint-disable-next-line no-warning-comments
// @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
// TODO remove in webpack 6
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/42919
Object.defineProperty(Dependency.prototype, "module", {
/**
* @deprecated
@ -352,8 +352,8 @@ Object.defineProperty(Dependency.prototype, "module", {
}
});
// eslint-disable-next-line no-warning-comments
// @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
// TODO remove in webpack 6
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/42919
Object.defineProperty(Dependency.prototype, "disconnect", {
get() {
throw new Error(

View File

@ -20,8 +20,10 @@ const makeSerializable = require("./util/makeSerializable");
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
/** @typedef {import("./Module").BuildCallback} BuildCallback */
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("./Module").SourceContext} SourceContext */
/** @typedef {import("./RequestShortener")} RequestShortener */
@ -80,7 +82,7 @@ class DllModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {
@ -107,7 +109,7 @@ class DllModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {

View File

@ -8,8 +8,8 @@
const DllModule = require("./DllModule");
const ModuleFactory = require("./ModuleFactory");
/** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
/** @typedef {import("./dependencies/DllEntryDependency")} DllEntryDependency */
class DllModuleFactory extends ModuleFactory {
@ -20,7 +20,7 @@ class DllModuleFactory extends ModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create(data, callback) {

View File

@ -819,8 +819,13 @@ class ExportsInfo {
/** @typedef {Map<string, RuntimeUsageStateType>} UsedInRuntime */
/** @typedef {{ module: Module, export: string[] }} TargetItemWithoutConnection */
/** @typedef {{ module: Module, connection: ModuleGraphConnection, export: string[] | undefined }} TargetItemWithConnection */
/** @typedef {(target: TargetItemWithConnection) => boolean} ResolveTargetFilter */
/** @typedef {(module: Module) => boolean} ValidTargetModuleFilter */
/** @typedef {{ connection: ModuleGraphConnection, export: string[], priority: number }} TargetItem */
/** @typedef {Map<Dependency | undefined, TargetItem>} Target */
@ -907,7 +912,7 @@ class ExportInfo {
// TODO webpack 5 remove
/**
* @private
* @param {*} v v
* @param {EXPECTED_ANY} v v
*/
set used(v) {
throw new Error("REMOVED");
@ -922,7 +927,7 @@ class ExportInfo {
// TODO webpack 5 remove
/**
* @private
* @param {*} v v
* @param {EXPECTED_ANY} v v
*/
set usedName(v) {
throw new Error("REMOVED");
@ -1007,7 +1012,7 @@ class ExportInfo {
}
/**
* @param {function(UsageStateType): boolean} condition compare with old value
* @param {(condition: UsageStateType) => boolean} condition compare with old value
* @param {UsageStateType} newValue set when condition is true
* @param {RuntimeSpec} runtime only apply to this runtime
* @returns {boolean} true when something has changed
@ -1252,7 +1257,7 @@ class ExportInfo {
/**
* @param {ModuleGraph} moduleGraph the module graph
* @param {function(TargetItemWithConnection): boolean} resolveTargetFilter filter function to further resolve target
* @param {ResolveTargetFilter} resolveTargetFilter filter function to further resolve target
* @returns {ExportInfo | ExportsInfo | undefined} the terminal binding export(s) info if known
*/
getTerminalBinding(moduleGraph, resolveTargetFilter = RETURNS_TRUE) {
@ -1295,7 +1300,7 @@ class ExportInfo {
/**
* @param {ModuleGraph} moduleGraph the module graph
* @param {function(Module): boolean} validTargetModuleFilter a valid target module
* @param {ValidTargetModuleFilter} validTargetModuleFilter a valid target module
* @returns {TargetItemWithoutConnection | null | undefined | false} the target, undefined when there is no target, false when no target is valid
*/
findTarget(moduleGraph, validTargetModuleFilter) {
@ -1304,7 +1309,7 @@ class ExportInfo {
/**
* @param {ModuleGraph} moduleGraph the module graph
* @param {function(Module): boolean} validTargetModuleFilter a valid target module
* @param {ValidTargetModuleFilter} validTargetModuleFilter a valid target module
* @param {Set<ExportInfo>} alreadyVisited set of already visited export info to avoid circular references
* @returns {TargetItemWithoutConnection | null | undefined | false} the target, undefined when there is no target, false when no target is valid
*/
@ -1345,7 +1350,7 @@ class ExportInfo {
/**
* @param {ModuleGraph} moduleGraph the module graph
* @param {function(TargetItemWithConnection): boolean} resolveTargetFilter filter function to further resolve target
* @param {ResolveTargetFilter} resolveTargetFilter filter function to further resolve target
* @returns {TargetItemWithConnection | undefined} the target
*/
getTarget(moduleGraph, resolveTargetFilter = RETURNS_TRUE) {
@ -1356,7 +1361,7 @@ class ExportInfo {
/**
* @param {ModuleGraph} moduleGraph the module graph
* @param {function(TargetItemWithConnection): boolean} resolveTargetFilter filter function to further resolve target
* @param {ResolveTargetFilter} resolveTargetFilter filter function to further resolve target
* @param {Set<ExportInfo> | undefined} alreadyVisited set of already visited export info to avoid circular references
* @returns {TargetItemWithConnection | CIRCULAR | undefined} the target
*/
@ -1454,8 +1459,8 @@ class ExportInfo {
/**
* Move the target forward as long resolveTargetFilter is fulfilled
* @param {ModuleGraph} moduleGraph the module graph
* @param {function(TargetItemWithConnection): boolean} resolveTargetFilter filter function to further resolve target
* @param {function(TargetItemWithConnection): ModuleGraphConnection=} updateOriginalConnection updates the original connection instead of using the target connection
* @param {ResolveTargetFilter} resolveTargetFilter filter function to further resolve target
* @param {(target: TargetItemWithConnection) => ModuleGraphConnection=} updateOriginalConnection updates the original connection instead of using the target connection
* @returns {TargetItemWithConnection | undefined} the resolved target when moved
*/
moveTarget(moduleGraph, resolveTargetFilter, updateOriginalConnection) {

View File

@ -37,11 +37,13 @@ const { register } = require("./util/serialization");
/** @typedef {import("./ExportsInfo")} ExportsInfo */
/** @typedef {import("./Generator").GenerateContext} GenerateContext */
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
/** @typedef {import("./Module").BuildCallback} BuildCallback */
/** @typedef {import("./Module").BuildInfo} BuildInfo */
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
/** @typedef {import("./ModuleGraph")} ModuleGraph */
@ -555,7 +557,7 @@ class ExternalModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -567,7 +569,7 @@ class ExternalModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -89,10 +89,12 @@ class ExternalModuleFactoryPlugin {
const dependency = data.dependencies[0];
const dependencyType = data.dependencyType;
/** @typedef {(err?: Error | null, externalModule?: ExternalModule) => void} HandleExternalCallback */
/**
* @param {ExternalValue} value the external config
* @param {ExternalType | undefined} type type of external
* @param {function((Error | null)=, ExternalModule=): void} callback callback
* @param {HandleExternalCallback} callback callback
* @returns {void}
*/
const handleExternal = (value, type, callback) => {
@ -176,7 +178,7 @@ class ExternalModuleFactoryPlugin {
/**
* @param {Externals} externals externals config
* @param {function((Error | null)=, ExternalModule=): void} callback callback
* @param {HandleExternalCallback} callback callback
* @returns {void}
*/
const handleExternals = (externals, callback) => {

View File

@ -604,9 +604,9 @@ const MIN_COMMON_SNAPSHOT_SIZE = 3;
*/
class SnapshotOptimization {
/**
* @param {function(Snapshot): boolean} has has value
* @param {function(Snapshot): SnapshotOptimizationValue<U, T> | undefined} get get value
* @param {function(Snapshot, SnapshotOptimizationValue<U, T>): void} set set value
* @param {(snapshot: Snapshot) => boolean} has has value
* @param {(snapshot: Snapshot) => SnapshotOptimizationValue<U, T> | undefined} get get value
* @param {(snapshot: Snapshot, value: SnapshotOptimizationValue<U, T>) => void} set set value
* @param {boolean=} useStartTime use the start time of snapshots
* @param {U=} isSet value is an Set instead of a Map
*/
@ -1045,6 +1045,8 @@ const addAll = (source, target) => {
/** @typedef {ContextFileSystemInfoEntry | "ignore" | null} ContextTimestamp */
/** @typedef {ResolvedContextFileSystemInfoEntry | "ignore" | null} ResolvedContextTimestamp */
/** @typedef {(err?: WebpackError | null, result?: boolean) => void} CheckSnapshotValidCallback */
/**
* Used to access information about the filesystem in a cached way
*/
@ -1074,7 +1076,7 @@ class FileSystemInfo {
/** @type {LoggedPaths | undefined} */
this._loggedPaths = logger ? new Set() : undefined;
this._hashFunction = hashFunction;
/** @type {WeakMap<Snapshot, boolean | (function((WebpackError | null)=, boolean=): void)[]>} */
/** @type {WeakMap<Snapshot, boolean | CheckSnapshotValidCallback[]>} */
this._snapshotCache = new WeakMap();
this._fileTimestampsOptimization = new SnapshotOptimization(
s => s.hasFileTimestamps(),
@ -1408,7 +1410,7 @@ class FileSystemInfo {
/**
* @param {string} path file path
* @param {function((WebpackError | null)=, FileTimestamp=): void} callback callback function
* @param {(err?: WebpackError | null, fileTimestamp?: FileTimestamp) => void} callback callback function
* @returns {void}
*/
getFileTimestamp(path, callback) {
@ -1419,7 +1421,7 @@ class FileSystemInfo {
/**
* @param {string} path context path
* @param {function((WebpackError | null)=, ResolvedContextTimestamp=): void} callback callback function
* @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback function
* @returns {void}
*/
getContextTimestamp(path, callback) {
@ -1446,7 +1448,7 @@ class FileSystemInfo {
/**
* @private
* @param {string} path context path
* @param {function((WebpackError | null)=, ContextTimestamp=): void} callback callback function
* @param {(err?: WebpackError | null, contextTimestamp?: ContextTimestamp) => void} callback callback function
* @returns {void}
*/
_getUnresolvedContextTimestamp(path, callback) {
@ -1457,7 +1459,7 @@ class FileSystemInfo {
/**
* @param {string} path file path
* @param {function((WebpackError | null)=, (string | null)=): void} callback callback function
* @param {(err?: WebpackError | null, hash?: string | null) => void} callback callback function
* @returns {void}
*/
getFileHash(path, callback) {
@ -1468,7 +1470,7 @@ class FileSystemInfo {
/**
* @param {string} path context path
* @param {function((WebpackError | null)=, string=): void} callback callback function
* @param {(err?: WebpackError | null, contextHash?: string) => void} callback callback function
* @returns {void}
*/
getContextHash(path, callback) {
@ -1492,7 +1494,7 @@ class FileSystemInfo {
/**
* @private
* @param {string} path context path
* @param {function((WebpackError | null)=, (ContextHash | null)=): void} callback callback function
* @param {(err?: WebpackError | null, contextHash?: ContextHash | null) => void} callback callback function
* @returns {void}
*/
_getUnresolvedContextHash(path, callback) {
@ -1503,7 +1505,7 @@ class FileSystemInfo {
/**
* @param {string} path context path
* @param {function((WebpackError | null)=, (ResolvedContextTimestampAndHash | null)=): void} callback callback function
* @param {(err?: WebpackError | null, resolvedContextTimestampAndHash?: ResolvedContextTimestampAndHash | null) => void} callback callback function
* @returns {void}
*/
getContextTsh(path, callback) {
@ -1525,7 +1527,7 @@ class FileSystemInfo {
/**
* @private
* @param {string} path context path
* @param {function((WebpackError | null)=, (ContextTimestampAndHash | null)=): void} callback callback function
* @param {(err?: WebpackError | null, contextTimestampAndHash?: ContextTimestampAndHash | null) => void} callback callback function
* @returns {void}
*/
_getUnresolvedContextTsh(path, callback) {
@ -1565,7 +1567,7 @@ class FileSystemInfo {
/**
* @param {string} context context directory
* @param {Iterable<string>} deps dependencies
* @param {function((Error | null)=, ResolveBuildDependenciesResult=): void} callback callback function
* @param {(err?: Error | null, resolveBuildDependenciesResult?: ResolveBuildDependenciesResult) => void} callback callback function
* @returns {void}
*/
resolveBuildDependencies(context, deps, callback) {
@ -2085,7 +2087,7 @@ class FileSystemInfo {
/**
* @param {ResolveResults} resolveResults results from resolving
* @param {function((Error | null)=, boolean=): void} callback callback with true when resolveResults resolve the same way
* @param {(err?: Error | null, result?: boolean) => void} callback callback with true when resolveResults resolve the same way
* @returns {void}
*/
checkResolveResultsValid(resolveResults, callback) {
@ -2164,7 +2166,7 @@ class FileSystemInfo {
* @param {Iterable<string> | null} directories all directories
* @param {Iterable<string> | null} missing all missing files or directories
* @param {SnapshotOptions | null | undefined} options options object (for future extensions)
* @param {function(WebpackError | null, Snapshot | null): void} callback callback function
* @param {(err: WebpackError | null, snapshot: Snapshot | null) => void} callback callback function
* @returns {void}
*/
createSnapshot(startTime, files, directories, missing, options, callback) {
@ -2614,7 +2616,7 @@ class FileSystemInfo {
// Fallback to normal snapshotting
/**
* @param {Set<string>} set set
* @param {function(Set<string>): void} fn fn
* @param {(set: Set<string>) => void} fn fn
*/
const process = (set, fn) => {
if (set.size === 0) return;
@ -2723,7 +2725,7 @@ class FileSystemInfo {
/**
* @param {Snapshot} snapshot the snapshot made
* @param {function((WebpackError | null)=, boolean=): void} callback callback function
* @param {CheckSnapshotValidCallback} callback callback function
* @returns {void}
*/
checkSnapshotValid(snapshot, callback) {
@ -2744,7 +2746,7 @@ class FileSystemInfo {
/**
* @private
* @param {Snapshot} snapshot the snapshot made
* @param {function((WebpackError | null)=, boolean=): void} callback callback function
* @param {CheckSnapshotValidCallback} callback callback function
* @returns {void}
*/
_checkSnapshotValidNoCache(snapshot, callback) {
@ -3326,7 +3328,7 @@ class FileSystemInfo {
/**
* @private
* @param {string} path path
* @param {function(WebpackError | null, TimestampAndHash=) : void} callback callback
* @param {(err: WebpackError | null, timestampAndHash?: TimestampAndHash) => void} callback callback
*/
_getFileTimestampAndHash(path, callback) {
/**
@ -3381,13 +3383,13 @@ class FileSystemInfo {
* @template ItemType
* @param {object} options options
* @param {string} options.path path
* @param {function(string): ItemType} options.fromImmutablePath called when context item is an immutable path
* @param {function(string): ItemType} options.fromManagedItem called when context item is a managed path
* @param {function(string, string, function((WebpackError | null)=, ItemType=): void): void} options.fromSymlink called when context item is a symlink
* @param {function(string, IStats, function((WebpackError | null)=, (ItemType | null)=): void): void} options.fromFile called when context item is a file
* @param {function(string, IStats, function((WebpackError | null)=, ItemType=): void): void} options.fromDirectory called when context item is a directory
* @param {function(string[], ItemType[]): T} options.reduce called from all context items
* @param {function((Error | null)=, (T | null)=): void} callback callback
* @param {(value: string) => ItemType} options.fromImmutablePath called when context item is an immutable path
* @param {(value: string) => ItemType} options.fromManagedItem called when context item is a managed path
* @param {(value: string, result: string, callback: (err?: WebpackError | null, itemType?: ItemType) => void) => void} options.fromSymlink called when context item is a symlink
* @param {(value: string, stats: IStats, callback: (err?: WebpackError | null, itemType?: ItemType | null) => void) => void} options.fromFile called when context item is a file
* @param {(value: string, stats: IStats, callback: (err?: WebpackError | null, itemType?: ItemType) => void) => void} options.fromDirectory called when context item is a directory
* @param {(arr: string[], arr1: ItemType[]) => T} options.reduce called from all context items
* @param {(err?: Error | null, result?: T | null) => void} callback callback
*/
_readContext(
{
@ -3605,7 +3607,7 @@ class FileSystemInfo {
/**
* @private
* @param {ContextFileSystemInfoEntry} entry entry
* @param {function((WebpackError | null)=, ResolvedContextTimestamp=): void} callback callback
* @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback
* @returns {void}
*/
_resolveContextTimestamp(entry, callback) {
@ -3725,7 +3727,7 @@ class FileSystemInfo {
/**
* @private
* @param {ContextHash} entry context hash
* @param {function(WebpackError | null, string=): void} callback callback
* @param {(err: WebpackError | null, contextHash?: string) => void} callback callback
* @returns {void}
*/
_resolveContextHash(entry, callback) {

View File

@ -32,7 +32,7 @@
* @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules
* @property {CodeGenerationResults=} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)
* @property {string} type which kind of code should be generated
* @property {function(): Map<string, any>=} getData get access to the code generation data
* @property {() => Map<string, any>=} getData get access to the code generation data
*/
/**

View File

@ -51,7 +51,7 @@ module.exports.makeWebpackError = makeWebpackError;
/**
* @template T
* @param {function(WebpackError | null, T=): void} callback webpack error callback
* @param {(err: WebpackError | null, result?: T) => void} callback webpack error callback
* @param {string} hook name of hook
* @returns {Callback<T>} generic callback
*/
@ -71,7 +71,7 @@ module.exports.makeWebpackErrorCallback = makeWebpackErrorCallback;
/**
* @template T
* @param {function(): T} fn function which will be wrapping in try catch
* @param {() => T} fn function which will be wrapping in try catch
* @param {string} hook name of hook
* @returns {T} the result
*/

View File

@ -7,8 +7,8 @@
const ModuleFactory = require("./ModuleFactory");
/** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
/**
@ -26,7 +26,7 @@ class IgnoreErrorModuleFactory extends ModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create(data, callback) {

View File

@ -62,7 +62,7 @@ class MainTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(RenderManifestEntry[], RenderManifestOptions): RenderManifestEntry[]} fn fn
* @param {(renderManifestEntries: RenderManifestEntry[], renderManifestOptions: RenderManifestOptions) => RenderManifestEntry[]} fn fn
*/
(options, fn) => {
compilation.hooks.renderManifest.tap(
@ -96,7 +96,7 @@ class MainTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(string, RenderBootstrapContext): string} fn fn
* @param {(value: string, renderBootstrapContext: RenderBootstrapContext) => string} fn fn
*/
(options, fn) => {
getJavascriptModulesPlugin()
@ -133,7 +133,7 @@ class MainTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Source, Chunk, string | undefined, ModuleTemplate, DependencyTemplates): Source} fn fn
* @param {(source: Source, chunk: Chunk, hash: string | undefined, moduleTemplate: ModuleTemplate, dependencyTemplates: DependencyTemplates) => Source} fn fn
*/
(options, fn) => {
getJavascriptModulesPlugin()
@ -165,7 +165,7 @@ class MainTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Source, Chunk, string | undefined): Source} fn fn
* @param {(source: Source, chunk: Chunk, hash: string | undefined) => Source} fn fn
*/
(options, fn) => {
getJavascriptModulesPlugin()
@ -191,7 +191,7 @@ class MainTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(string, object, AssetInfo | undefined): string} fn fn
* @param {(value: string, path: PathData, assetInfo: AssetInfo | undefined) => string} fn fn
*/
(options, fn) => {
compilation.hooks.assetPath.tap(options, fn);
@ -215,7 +215,7 @@ class MainTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Hash): void} fn fn
* @param {(hash: Hash) => void} fn fn
*/
(options, fn) => {
compilation.hooks.fullHash.tap(options, fn);
@ -229,7 +229,7 @@ class MainTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Hash, Chunk): void} fn fn
* @param {(hash: Hash, chunk: Chunk) => void} fn fn
*/
(options, fn) => {
getJavascriptModulesPlugin()

View File

@ -134,6 +134,10 @@ const makeSerializable = require("./util/makeSerializable");
* @property {ValueCacheVersions} valueCacheVersions
*/
/** @typedef {(err?: WebpackError | null, needBuild?: boolean) => void} NeedBuildCallback */
/** @typedef {(err?: WebpackError) => void} BuildCallback */
/** @typedef {KnownBuildMeta & Record<string, any>} BuildMeta */
/** @typedef {KnownBuildInfo & Record<string, any>} BuildInfo */
@ -777,7 +781,7 @@ class Module extends DependenciesBlock {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -860,7 +864,7 @@ class Module extends DependenciesBlock {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {
@ -1121,8 +1125,7 @@ class Module extends DependenciesBlock {
makeSerializable(Module, "webpack/lib/Module");
// TODO remove in webpack 6
// eslint-disable-next-line no-warning-comments
// @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/42919
Object.defineProperty(Module.prototype, "hasEqualsChunks", {
get() {
throw new Error(
@ -1132,8 +1135,7 @@ Object.defineProperty(Module.prototype, "hasEqualsChunks", {
});
// TODO remove in webpack 6
// eslint-disable-next-line no-warning-comments
// @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/42919
Object.defineProperty(Module.prototype, "isUsed", {
get() {
throw new Error(
@ -1179,8 +1181,7 @@ Object.defineProperty(Module.prototype, "warnings", {
});
// TODO remove in webpack 6
// eslint-disable-next-line no-warning-comments
// @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/42919
Object.defineProperty(Module.prototype, "used", {
get() {
throw new Error(

View File

@ -33,12 +33,16 @@
* @property {Dependency[]} dependencies
*/
/**
* @typedef {(err?: Error | null, result?: ModuleFactoryResult) => void} ModuleFactoryCallback
*/
class ModuleFactory {
/* istanbul ignore next */
/**
* @abstract
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create(data, callback) {

View File

@ -203,7 +203,7 @@ ModuleFilenameHelpers.createFilename = (
}
// TODO webpack 6: consider removing alternatives without dashes
/** @type {Map<string, function(): string>} */
/** @type {Map<string, () => string>} */
const replacements = new Map([
["identifier", identifier],
["short-identifier", shortIdentifier],

View File

@ -119,6 +119,8 @@ class ModuleGraphModule {
}
}
/** @typedef {(moduleGraphConnection: ModuleGraphConnection) => boolean} FilterConnection */
class ModuleGraph {
constructor() {
/**
@ -331,7 +333,7 @@ class ModuleGraph {
/**
* @param {Module} oldModule the old referencing module
* @param {Module} newModule the new referencing module
* @param {function(ModuleGraphConnection): boolean} filterConnection filter predicate for replacement
* @param {FilterConnection} filterConnection filter predicate for replacement
* @returns {void}
*/
moveModuleConnections(oldModule, newModule, filterConnection) {
@ -368,7 +370,7 @@ class ModuleGraph {
/**
* @param {Module} oldModule the old referencing module
* @param {Module} newModule the new referencing module
* @param {function(ModuleGraphConnection): boolean} filterConnection filter predicate for replacement
* @param {FilterConnection} filterConnection filter predicate for replacement
* @returns {void}
*/
copyOutgoingModuleConnections(oldModule, newModule, filterConnection) {

View File

@ -75,7 +75,6 @@ class ModuleGraphConnection {
this.weak = weak;
this.conditional = Boolean(condition);
this._active = condition !== false;
/** @type {(function(ModuleGraphConnection, RuntimeSpec): ConnectionState) | undefined} */
this.condition = condition || undefined;
/** @type {Set<string> | undefined} */
this.explanations = undefined;
@ -103,15 +102,16 @@ class ModuleGraphConnection {
}
/**
* @param {function(ModuleGraphConnection, RuntimeSpec): ConnectionState} condition condition for the connection
* @param {GetConditionFn} condition condition for the connection
* @returns {void}
*/
addCondition(condition) {
if (this.conditional) {
const old =
/** @type {(function(ModuleGraphConnection, RuntimeSpec): ConnectionState)} */
/** @type {GetConditionFn} */
(this.condition);
this.condition = (c, r) =>
/** @type {GetConditionFn} */
(this.condition) = (c, r) =>
intersectConnectionStates(old(c, r), condition(c, r));
} else if (this._active) {
this.conditional = true;
@ -143,9 +143,7 @@ class ModuleGraphConnection {
if (!this.conditional) return this._active;
return (
/** @type {(function(ModuleGraphConnection, RuntimeSpec): ConnectionState)} */ (
this.condition
)(this, runtime) !== false
/** @type {GetConditionFn} */ (this.condition)(this, runtime) !== false
);
}
@ -156,9 +154,7 @@ class ModuleGraphConnection {
isTargetActive(runtime) {
if (!this.conditional) return this._active;
return (
/** @type {(function(ModuleGraphConnection, RuntimeSpec): ConnectionState)} */ (
this.condition
)(this, runtime) === true
/** @type {GetConditionFn} */ (this.condition)(this, runtime) === true
);
}
@ -168,9 +164,7 @@ class ModuleGraphConnection {
*/
getActiveState(runtime) {
if (!this.conditional) return this._active;
return /** @type {(function(ModuleGraphConnection, RuntimeSpec): ConnectionState)} */ (
this.condition
)(this, runtime);
return /** @type {GetConditionFn} */ (this.condition)(this, runtime);
}
/**

View File

@ -44,7 +44,7 @@ class ModuleTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Source, Module, ChunkRenderContext, DependencyTemplates): Source} fn fn
* @param {(source: Source, module: Module, chunkRenderContext: ChunkRenderContext, dependencyTemplates: DependencyTemplates) => Source} fn fn
*/
(options, fn) => {
getJavascriptModulesPlugin()
@ -69,7 +69,7 @@ class ModuleTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Source, Module, ChunkRenderContext, DependencyTemplates): Source} fn fn
* @param {(source: Source, module: Module, chunkRenderContext: ChunkRenderContext, dependencyTemplates: DependencyTemplates) => Source} fn fn
*/
(options, fn) => {
getJavascriptModulesPlugin()
@ -94,7 +94,7 @@ class ModuleTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Source, Module, ChunkRenderContext, DependencyTemplates): Source} fn fn
* @param {(source: Source, module: Module, chunkRenderContext: ChunkRenderContext, dependencyTemplates: DependencyTemplates) => Source} fn fn
*/
(options, fn) => {
getJavascriptModulesPlugin()
@ -119,7 +119,7 @@ class ModuleTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Source, Module, ChunkRenderContext, DependencyTemplates): Source} fn fn
* @param {(source: Source, module: Module, chunkRenderContext: ChunkRenderContext, dependencyTemplates: DependencyTemplates) => Source} fn fn
*/
(options, fn) => {
getJavascriptModulesPlugin()
@ -144,7 +144,7 @@ class ModuleTemplate {
/**
* @template AdditionalOptions
* @param {string | Tap & IfSet<AdditionalOptions>} options options
* @param {function(Hash): void} fn fn
* @param {(hash: Hash) => void} fn fn
*/
(options, fn) => {
compilation.hooks.fullHash.tap(options, fn);

View File

@ -223,7 +223,7 @@ module.exports = class MultiCompiler {
}
/**
* @param {string | (function(): string)} name name of the logger, or function called once to get the logger name
* @param {string | (() => string)} name name of the logger, or function called once to get the logger name
* @returns {Logger} a logger with that name
*/
getInfrastructureLogger(name) {
@ -377,8 +377,8 @@ module.exports = class MultiCompiler {
/**
* @template SetupResult
* @param {function(Compiler, number, Callback<Stats>, function(): boolean, function(): void, function(): void): SetupResult} setup setup a single compiler
* @param {function(Compiler, SetupResult, Callback<Stats>): void} run run/continue a single compiler
* @param {(compiler: Compiler, index: number, doneCallback: Callback<Stats>, isBlocked: () => boolean, setChanged: () => void, setInvalid: () => void) => SetupResult} setup setup a single compiler
* @param {(compiler: Compiler, setupResult: SetupResult, callback: Callback<Stats>) => void} run run/continue a single compiler
* @param {Callback<MultiStats>} callback callback when all compilers are done, result includes Stats of all changed compilers
* @returns {SetupResult[]} result of setup
*/

View File

@ -70,6 +70,8 @@ const memoize = require("./util/memoize");
/** @typedef {import("./Module").KnownBuildInfo} KnownBuildInfo */
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("./Module").BuildCallback} BuildCallback */
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
/** @typedef {import("./Module").UnsafeCacheData} UnsafeCacheData */
/** @typedef {import("./ModuleGraph")} ModuleGraph */
@ -158,7 +160,7 @@ const contextifySourceUrl = (context, source, associatedObjectForCache) => {
const contextifySourceMap = (context, sourceMap, associatedObjectForCache) => {
if (!Array.isArray(sourceMap.sources)) return sourceMap;
const { sourceRoot } = sourceMap;
/** @type {function(string): string} */
/** @type {(source: string) => string} */
const mapper = !sourceRoot
? source => source
: sourceRoot.endsWith("/")
@ -880,7 +882,7 @@ class NormalModule extends Module {
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {NormalModuleCompilationHooks} hooks the hooks
* @param {function((WebpackError | null)=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
_doBuild(options, compilation, resolver, fs, hooks, callback) {
@ -1015,8 +1017,7 @@ class NormalModule extends Module {
loaderContext._compilation =
loaderContext._compiler =
loaderContext._module =
// eslint-disable-next-line no-warning-comments
// @ts-ignore
// @ts-expect-error avoid memory leaking
loaderContext.fs =
undefined;
@ -1140,7 +1141,7 @@ class NormalModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {
@ -1434,7 +1435,7 @@ class NormalModule extends Module {
runtimeRequirements.add(RuntimeGlobals.thisAsExports);
}
/** @type {function(): Map<string, any>} */
/** @type {() => Map<string, any>} */
const getData = () => this._codeGeneratorData;
const sources = new Map();
@ -1486,7 +1487,7 @@ class NormalModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {

View File

@ -37,6 +37,7 @@ const {
/** @typedef {import("../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
/** @typedef {import("../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
/** @typedef {import("./Generator")} Generator */
/** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateDataContextInfo} ModuleFactoryCreateDataContextInfo */
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
@ -850,7 +851,7 @@ class NormalModuleFactory extends ModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create(data, callback) {

View File

@ -8,15 +8,16 @@
const { join, dirname } = require("./util/fs");
/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
/** @typedef {function(import("./NormalModuleFactory").ResolveData): void} ModuleReplacer */
/** @typedef {(resolveData: ResolveData) => void} ModuleReplacer */
class NormalModuleReplacementPlugin {
/**
* Create an instance of the plugin
* @param {RegExp} resourceRegExp the resource matcher
* @param {string|ModuleReplacer} newResource the resource replacement
* @param {string | ModuleReplacer} newResource the resource replacement
*/
constructor(resourceRegExp, newResource) {
this.resourceRegExp = resourceRegExp;

View File

@ -7,13 +7,13 @@
const ModuleFactory = require("./ModuleFactory");
/** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
class NullFactory extends ModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create(data, callback) {

View File

@ -479,8 +479,7 @@ class ProgressPlugin {
compilation.hooks.failedEntry.tap("ProgressPlugin", entryDone);
compilation.hooks.succeedEntry.tap("ProgressPlugin", entryDone);
// avoid dynamic require if bundled with webpack
// @ts-expect-error
// @ts-expect-error avoid dynamic require if bundled with webpack
if (typeof __webpack_require__ !== "function") {
const requiredLoaders = new Set();
NormalModule.getCompilationHooks(compilation).beforeLoaders.tap(

View File

@ -18,8 +18,10 @@ const makeSerializable = require("./util/makeSerializable");
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
/** @typedef {import("./Module").BuildCallback} BuildCallback */
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
/** @typedef {import("./RequestShortener")} RequestShortener */
@ -80,7 +82,7 @@ class RawModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -92,7 +94,7 @@ class RawModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -23,7 +23,7 @@ const {
/** @typedef {WebpackResolveOptions & {dependencyType?: string, resolveToContext?: boolean }} ResolveOptionsWithDependencyType */
/**
* @typedef {object} WithOptions
* @property {function(Partial<ResolveOptionsWithDependencyType>): ResolverWithOptions} withOptions create a resolver with additional/different options
* @property {(options: Partial<ResolveOptionsWithDependencyType>) => ResolverWithOptions} withOptions create a resolver with additional/different options
*/
/** @typedef {Resolver & WithOptions} ResolverWithOptions */

View File

@ -18,8 +18,10 @@ const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
/** @typedef {import("./Compilation")} Compilation */
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
/** @typedef {import("./Module").BuildCallback} BuildCallback */
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("./RequestShortener")} RequestShortener */
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
@ -79,7 +81,7 @@ class RuntimeModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -91,7 +93,7 @@ class RuntimeModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -5,8 +5,8 @@
"use strict";
/** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
/** @typedef {import("./ModuleGraph")} ModuleGraph */
class SelfModuleFactory {
@ -19,7 +19,7 @@ class SelfModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create(data, callback) {

View File

@ -60,7 +60,7 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
/**
* @typedef {object} RenderManifestEntryTemplated
* @property {function(): Source} render
* @property {() => Source} render
* @property {TemplatePath} filenameTemplate
* @property {PathData=} pathOptions
* @property {AssetInfo=} info
@ -71,7 +71,7 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
/**
* @typedef {object} RenderManifestEntryStatic
* @property {function(): Source} render
* @property {() => Source} render
* @property {string} filename
* @property {AssetInfo} info
* @property {string} identifier
@ -85,7 +85,7 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
*/
/**
* @typedef {function(Module, number): boolean} ModuleFilterPredicate
* @typedef {(module: Module) => boolean} ModuleFilterPredicate
*/
class Template {
@ -284,7 +284,7 @@ class Template {
/**
* @param {ChunkRenderContext} renderContext render context
* @param {Module[]} modules modules to render (should be ordered by identifier)
* @param {function(Module): Source | null} renderModule function to render a module
* @param {(module: Module) => Source | null} renderModule function to render a module
* @param {string=} prefix applying prefix strings
* @returns {Source | null} rendered chunk modules in a Source object or null if no modules
*/

View File

@ -116,7 +116,7 @@ const deprecatedFunction = (() => () => {})();
* @param {Function} fn function
* @param {string} message message
* @param {string} code code
* @returns {function(...any[]): void} function with deprecation output
* @returns {(...args: any[]) => void} function with deprecation output
*/
const deprecated = (fn, message, code) => {
let d = deprecationCache.get(message);
@ -130,7 +130,7 @@ const deprecated = (fn, message, code) => {
};
};
/** @typedef {string | function(PathData, AssetInfo=): string} TemplatePath */
/** @typedef {string | ((pathData: PathData, assetInfo?: AssetInfo) => string)} TemplatePath */
/**
* @param {TemplatePath} path the raw path

View File

@ -15,8 +15,10 @@ const makeSerializable = require("../util/makeSerializable");
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
/** @typedef {import("../Module").BuildCallback} BuildCallback */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
/** @typedef {import("../RequestShortener")} RequestShortener */
@ -77,7 +79,7 @@ class RawDataUrlModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -89,7 +91,7 @@ class RawDataUrlModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -394,7 +394,7 @@ class Pack {
const mergedItems = new Set();
/** @type {Items} */
const mergedUsedItems = new Set();
/** @type {(function(Map<string, any>): Promise<void>)[]} */
/** @type {((map: Map<string, any>) => Promise<void>)[]} */
const addToMergedMap = [];
for (const content of mergedContent) {
for (const identifier of content.items) {
@ -795,7 +795,7 @@ makeSerializable(
"PackContentItems"
);
/** @typedef {(function(): Promise<PackContentItems> | PackContentItems)} LazyFunction */
/** @typedef {(() => Promise<PackContentItems> | PackContentItems)} LazyFunction */
class PackContent {
/*
@ -820,7 +820,7 @@ class PackContent {
/**
* @param {Items} items keys
* @param {Items} usedItems used keys
* @param {PackContentItems | function(): Promise<PackContentItems>} dataOrFn sync or async content
* @param {PackContentItems | (() => Promise<PackContentItems>)} dataOrFn sync or async content
* @param {Logger=} logger logger for logging
* @param {string=} lazyName name of dataOrFn for logging
*/
@ -961,7 +961,7 @@ class PackContent {
/**
* @template T
* @param {function(any): function(): Promise<PackContentItems> | PackContentItems} write write function
* @param {(item: any) => (() => Promise<PackContentItems> | PackContentItems)} write write function
* @returns {void}
*/
writeLazy(write) {

View File

@ -130,7 +130,7 @@ class ResolverCachePlugin {
});
});
/** @typedef {function((Error | null)=, (ResolveRequest | null)=): void} Callback */
/** @typedef {(err?: Error | null, resolveRequest?: ResolveRequest | null) => void} Callback */
/** @typedef {ResolveRequest & { _ResolverCachePluginCacheMiss: true }} ResolveRequestWithCacheMiss */
/**
@ -250,9 +250,10 @@ class ResolverCachePlugin {
};
compiler.resolverFactory.hooks.resolver.intercept({
factory(type, _hook) {
/** @type {Map<string, (function(Error=, ResolveRequest=): void)[]>} */
/** @typedef {(err?: Error, resolveRequest?: ResolveRequest) => void} ActiveRequest */
/** @type {Map<string, ActiveRequest[]>} */
const activeRequests = new Map();
/** @type {Map<string, [function(Error=, ResolveRequest=): void, NonNullable<ResolveContext["yield"]>][]>} */
/** @type {Map<string, [ActiveRequest, NonNullable<ResolveContext["yield"]>][]>} */
const activeRequestsWithYield = new Map();
const hook =
/** @type {SyncHook<[Resolver, ResolveOptions, ResolveOptionsWithDependencyType]>} */
@ -306,7 +307,7 @@ class ResolverCachePlugin {
let yields;
/**
* @type {function((Error | null)=, (ResolveRequest | ResolveRequest[] | null)=): void}
* @type {(err?: Error | null, result?: ResolveRequest | ResolveRequest[] | null) => void}
*/
const done = withYield
? (err, result) => {

View File

@ -12,7 +12,7 @@ const createHash = require("../util/createHash");
/**
* @typedef {object} HashableObject
* @property {function(Hash): void} updateHash
* @property {(hash: Hash) => void} updateHash
*/
class LazyHashedEtag {

View File

@ -100,7 +100,7 @@ const D = (obj, prop, value) => {
* @template {keyof T} P
* @param {T} obj an object
* @param {P} prop a property of this object
* @param {function(): T[P]} factory a default value factory for the property
* @param {() => T[P]} factory a default value factory for the property
* @returns {void}
*/
const F = (obj, prop, factory) => {
@ -118,7 +118,7 @@ const F = (obj, prop, factory) => {
* @template {keyof T} P
* @param {T} obj an object
* @param {P} prop a property of this object
* @param {function(): T[P]} factory a default value factory for the property
* @param {() => T[P]} factory a default value factory for the property
* @returns {void}
*/
const A = (obj, prop, factory) => {
@ -1281,7 +1281,7 @@ const applyOutputDefaults = (
}
/**
* @param {function(EntryDescription): void} fn iterator
* @param {(entryDescription: EntryDescription) => void} fn iterator
* @returns {void}
*/
const forEachEntry = fn => {
@ -1600,14 +1600,14 @@ const getResolveDefaults = ({
const browserField =
tp && tp.web && (!tp.node || (tp.electron && tp.electronRenderer));
/** @type {function(): ResolveOptions} */
/** @type {() => ResolveOptions} */
const cjsDeps = () => ({
aliasFields: browserField ? ["browser"] : [],
mainFields: browserField ? ["browser", "module", "..."] : ["module", "..."],
conditionNames: ["require", "module", "..."],
extensions: [...jsExtensions]
});
/** @type {function(): ResolveOptions} */
/** @type {() => ResolveOptions} */
const esmDeps = () => ({
aliasFields: browserField ? ["browser"] : [],
mainFields: browserField ? ["browser", "module", "..."] : ["module", "..."],

View File

@ -44,8 +44,8 @@ const handledDeprecatedNoEmitOnErrors = util.deprecate(
/**
* @template T
* @template R
* @param {T|undefined} value value or not
* @param {function(T): R} fn nested handler
* @param {T | undefined} value value or not
* @param {(value: T) => R} fn nested handler
* @returns {R} result value
*/
const nestedConfig = (value, fn) =>
@ -60,9 +60,9 @@ const cloneObject = value => /** @type {T} */ ({ ...value });
/**
* @template T
* @template R
* @param {T|undefined} value value or not
* @param {function(T): R} fn nested handler
* @returns {R|undefined} result value
* @param {T | undefined} value value or not
* @param {(value: T) => R} fn nested handler
* @returns {R | undefined} result value
*/
const optionalNestedConfig = (value, fn) =>
value === undefined ? undefined : fn(value);
@ -70,18 +70,18 @@ const optionalNestedConfig = (value, fn) =>
/**
* @template T
* @template R
* @param {T[]|undefined} value array or not
* @param {function(T[]): R[]} fn nested handler
* @returns {R[]|undefined} cloned value
* @param {T[] | undefined} value array or not
* @param {(value: T[]) => R[]} fn nested handler
* @returns {R[] | undefined} cloned value
*/
const nestedArray = (value, fn) => (Array.isArray(value) ? fn(value) : fn([]));
/**
* @template T
* @template R
* @param {T[]|undefined} value array or not
* @param {function(T[]): R[]} fn nested handler
* @returns {R[]|undefined} cloned value
* @param {T[] | undefined} value array or not
* @param {(value: T[]) => R[]} fn nested handler
* @returns {R[] | undefined} cloned value
*/
const optionalNestedArray = (value, fn) =>
Array.isArray(value) ? fn(value) : undefined;
@ -90,8 +90,8 @@ const optionalNestedArray = (value, fn) =>
* @template T
* @template R
* @param {Record<string, T>|undefined} value value or not
* @param {function(T): R} fn nested handler
* @param {Record<string, function(T): R>=} customKeys custom nested handler for some keys
* @param {(value: T) => R} fn nested handler
* @param {Record<string, (value: T) => R>=} customKeys custom nested handler for some keys
* @returns {Record<string, R>} result value
*/
const keyedNestedConfig = (value, fn, customKeys) => {

View File

@ -20,9 +20,11 @@ const ContainerExposedDependency = require("./ContainerExposedDependency");
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module").BuildCallback} BuildCallback */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
/** @typedef {import("../RequestShortener")} RequestShortener */
@ -91,7 +93,7 @@ class ContainerEntryModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -103,7 +105,7 @@ class ContainerEntryModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -8,14 +8,14 @@
const ModuleFactory = require("../ModuleFactory");
const ContainerEntryModule = require("./ContainerEntryModule");
/** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("../ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
/** @typedef {import("./ContainerEntryDependency")} ContainerEntryDependency */
module.exports = class ContainerEntryModuleFactory extends ModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create({ dependencies: [dependency] }, callback) {

View File

@ -19,9 +19,11 @@ const FallbackItemDependency = require("./FallbackItemDependency");
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module").BuildCallback} BuildCallback */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
/** @typedef {import("../RequestShortener")} RequestShortener */
@ -80,7 +82,7 @@ class FallbackModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -92,7 +94,7 @@ class FallbackModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -8,14 +8,14 @@
const ModuleFactory = require("../ModuleFactory");
const FallbackModule = require("./FallbackModule");
/** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("../ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
/** @typedef {import("./FallbackDependency")} FallbackDependency */
module.exports = class FallbackModuleFactory extends ModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create({ dependencies: [dependency] }, callback) {

View File

@ -20,9 +20,11 @@ const RemoteToExternalDependency = require("./RemoteToExternalDependency");
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module").BuildCallback} BuildCallback */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
/** @typedef {import("../RequestShortener")} RequestShortener */
@ -80,7 +82,7 @@ class RemoteModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -92,7 +94,7 @@ class RemoteModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -19,9 +19,9 @@
* @template T
* @template N
* @param {ContainerOptionsFormat<T>} options options passed by the user
* @param {function(string | string[], string) : N} normalizeSimple normalize a simple item
* @param {function(T, string) : N} normalizeOptions normalize a complex item
* @param {function(string, N): void} fn processing function
* @param {(item: string | string[], itemOrKey: string) => N} normalizeSimple normalize a simple item
* @param {(value: T, key: string) => N} normalizeOptions normalize a complex item
* @param {(item: string, normalized: N) => void} fn processing function
* @returns {void}
*/
const process = (options, normalizeSimple, normalizeOptions, fn) => {
@ -66,8 +66,8 @@ const process = (options, normalizeSimple, normalizeOptions, fn) => {
* @template T
* @template R
* @param {ContainerOptionsFormat<T>} options options passed by the user
* @param {function(string | string[], string) : R} normalizeSimple normalize a simple item
* @param {function(T, string) : R} normalizeOptions normalize a complex item
* @param {(item: string | string[], itemOrKey: string) => R} normalizeSimple normalize a simple item
* @param {(value: T, key: string) => R} normalizeOptions normalize a complex item
* @returns {[string, R][]} parsed options
*/
const parseOptions = (options, normalizeSimple, normalizeOptions) => {

View File

@ -95,7 +95,7 @@ const getCssLoadingRuntimeModule = memoize(() =>
/**
* @param {string} name name
* @returns {{oneOf: [{$ref: string}], definitions: *}} schema
* @returns {{ oneOf: [{ $ref: string }], definitions: import("../../schemas/WebpackOptions.json")["definitions"] }} schema
*/
const getSchema = name => {
const { definitions } = require("../../schemas/WebpackOptions.json");
@ -740,7 +740,7 @@ class CssModulesPlugin {
}
/**
* @param {CssModule} module css module
* @param {CssModule} module css module
* @param {ChunkRenderContext} renderContext options object
* @param {CompilationHooks} hooks hooks
* @returns {Source} css module source

View File

@ -7,25 +7,25 @@
/**
* @typedef {object} CssTokenCallbacks
* @property {(function(string, number, number, number, number): number)=} url
* @property {(function(string, number, number): number)=} comment
* @property {(function(string, number, number): number)=} string
* @property {(function(string, number, number): number)=} leftParenthesis
* @property {(function(string, number, number): number)=} rightParenthesis
* @property {(function(string, number, number): number)=} function
* @property {(function(string, number, number): number)=} colon
* @property {(function(string, number, number): number)=} atKeyword
* @property {(function(string, number, number): number)=} delim
* @property {(function(string, number, number): number)=} identifier
* @property {(function(string, number, number, boolean): number)=} hash
* @property {(function(string, number, number): number)=} leftCurlyBracket
* @property {(function(string, number, number): number)=} rightCurlyBracket
* @property {(function(string, number, number): number)=} semicolon
* @property {(function(string, number, number): number)=} comma
* @property {(function(): boolean)=} needTerminate
* @property {((input: string, start: number, end: number, innerStart: number, innerEnd: number) => number)=} url
* @property {((input: string, start: number, end: number) => number)=} comment
* @property {((input: string, start: number, end: number) => number)=} string
* @property {((input: string, start: number, end: number) => number)=} leftParenthesis
* @property {((input: string, start: number, end: number) => number)=} rightParenthesis
* @property {((input: string, start: number, end: number) => number)=} function
* @property {((input: string, start: number, end: number) => number)=} colon
* @property {((input: string, start: number, end: number) => number)=} atKeyword
* @property {((input: string, start: number, end: number) => number)=} delim
* @property {((input: string, start: number, end: number) => number)=} identifier
* @property {((input: string, start: number, end: number, isId: boolean) => number)=} hash
* @property {((input: string, start: number, end: number) => number)=} leftCurlyBracket
* @property {((input: string, start: number, end: number) => number)=} rightCurlyBracket
* @property {((input: string, start: number, end: number) => number)=} semicolon
* @property {((input: string, start: number, end: number) => number)=} comma
* @property {(() => boolean)=} needTerminate
*/
/** @typedef {function(string, number, CssTokenCallbacks): number} CharHandler */
/** @typedef {(input: string, pos: number, callbacks: CssTokenCallbacks) => number} CharHandler */
// spec: https://drafts.csswg.org/css-syntax/

View File

@ -140,7 +140,7 @@ class AMDPlugin {
/**
* @param {string} optionExpr option expression
* @param {string} rootName root name
* @param {function(): TODO} getMembers callback
* @param {() => TODO} getMembers callback
*/
const tapOptionsHooks = (optionExpr, rootName, getMembers) => {
parser.hooks.expression

View File

@ -271,8 +271,7 @@ class LoaderPlugin {
);
};
// eslint-disable-next-line no-warning-comments
// @ts-ignore Overloading doesn't work
// @ts-expect-error overloading doesn't work
loaderContext.importModule = (request, options, callback) => {
if (!callback) {
return new Promise((resolve, reject) => {

View File

@ -23,14 +23,16 @@ const { registerNotSerializable } = require("../util/serialization");
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
/** @typedef {import("../Module").BuildCallback} BuildCallback */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
/** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("../ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
/** @typedef {import("../RequestShortener")} RequestShortener */
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
/** @typedef {import("../WebpackError")} WebpackError */
@ -42,8 +44,8 @@ const { registerNotSerializable } = require("../util/serialization");
/**
* @typedef {object} BackendApi
* @property {function(function((Error | null)=) : void): void} dispose
* @property {function(Module): ModuleResult} module
* @property {(callback: (err?: (Error | null)) => void) => void} dispose
* @property {(module: Module) => ModuleResult} module
*/
const HMR_DEPENDENCY_TYPES = new Set([
@ -169,7 +171,7 @@ class LazyCompilationProxyModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -181,7 +183,7 @@ class LazyCompilationProxyModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {
@ -315,7 +317,7 @@ class LazyCompilationDependencyFactory extends ModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create(data, callback) {
@ -331,7 +333,7 @@ class LazyCompilationDependencyFactory extends ModuleFactory {
/**
* @callback BackendHandler
* @param {Compiler} compiler compiler
* @param {function(Error | null, BackendApi=): void} callback callback
* @param {(err: Error | null, backendApi?: BackendApi) => void} callback callback
* @returns {void}
*/
@ -347,7 +349,7 @@ class LazyCompilationPlugin {
* @param {BackendHandler | PromiseBackendHandler} options.backend the backend
* @param {boolean} options.entries true, when entries are lazy compiled
* @param {boolean} options.imports true, when import() modules are lazy compiled
* @param {RegExp | string | (function(Module): boolean) | undefined} options.test additional filter for lazy compiled entrypoint modules
* @param {RegExp | string | ((module: Module) => boolean) | undefined} options.test additional filter for lazy compiled entrypoint modules
*/
constructor({ backend, entries, imports, test }) {
this.backend = backend;

View File

@ -43,7 +43,7 @@ module.exports = options => (compiler, callback) => {
(options.server)
);
})();
/** @type {function(Server): void} */
/** @type {(server: Server) => void} */
const listen =
typeof options.listen === "function"
? options.listen

View File

@ -20,7 +20,7 @@ const {
/**
* @typedef {object} DeterministicModuleIdsPluginOptions
* @property {string=} context context relative to which module identifiers are computed
* @property {function(Module): boolean=} test selector function for modules
* @property {((module: Module) => boolean)=} test selector function for modules
* @property {number=} maxLength maximum id length in digits (used as starting point)
* @property {number=} salt hash salt for ids
* @property {boolean=} fixedLength do not increase the maxLength to find an optimal id space size

View File

@ -226,7 +226,7 @@ const addToMapOfItems = (map, key, value) => {
/**
* @param {Compilation} compilation the compilation
* @param {function(Module): boolean=} filter filter modules
* @param {((module: Module) => boolean)=} filter filter modules
* @returns {[Set<string>, Module[]]} used module ids as strings and modules without id matching the filter
*/
const getUsedModuleIdsAndModules = (compilation, filter) => {
@ -286,11 +286,11 @@ module.exports.getUsedChunkIds = getUsedChunkIds;
/**
* @template T
* @param {Iterable<T>} items list of items to be named
* @param {function(T): string} getShortName get a short name for an item
* @param {function(T, string): string} getLongName get a long name for an item
* @param {function(T, T): -1|0|1} comparator order of items
* @param {(item: T) => string} getShortName get a short name for an item
* @param {(item: T, name: string) => string} getLongName get a long name for an item
* @param {(a: T, b: T) => -1 | 0 | 1} comparator order of items
* @param {Set<string>} usedIds already used ids, will not be assigned
* @param {function(T, string): void} assignName assign a name to an item
* @param {(item: T, name: string) => void} assignName assign a name to an item
* @returns {T[]} list of items without a name
*/
const assignNames = (
@ -354,9 +354,9 @@ module.exports.assignNames = assignNames;
/**
* @template T
* @param {T[]} items list of items to be named
* @param {function(T): string} getName get a name for an item
* @param {function(T, T): -1|0|1} comparator order of items
* @param {function(T, number): boolean} assignId assign an id to an item
* @param {(item: T) => string} getName get a name for an item
* @param {(a: T, n: T) => -1 | 0 | 1} comparator order of items
* @param {(item: T, id: number) => boolean} assignId assign an id to an item
* @param {number[]} ranges usable ranges for ids
* @param {number} expandFactor factor to create more ranges
* @param {number} extraSpace extra space to allocate, i. e. when some ids are already used

View File

@ -19,7 +19,7 @@ class SyncModuleIdsPlugin {
* @param {object} options options
* @param {string} options.path path to file
* @param {string=} options.context context for module names
* @param {function(Module): boolean} options.test selector for modules
* @param {((module: Module) => boolean)=} options.test selector for modules
* @param {"read" | "create" | "merge" | "update"=} options.mode operation mode (defaults to merge)
*/
constructor({ path, context, test, mode }) {

View File

@ -65,7 +65,7 @@ const memoize = require("./util/memoize");
/**
* @template {Function} T
* @param {function(): T} factory factory function
* @param {() => T} factory factory function
* @returns {T} function
*/
const lazyFunction = factory => {
@ -120,13 +120,13 @@ module.exports = mergeExports(fn, {
return require("./webpack");
},
/**
* @returns {function(Configuration | Configuration[]): void} validate fn
* @returns {(configuration: Configuration | Configuration[]) => void} validate fn
*/
get validate() {
const webpackOptionsSchemaCheck = require("../schemas/WebpackOptions.check.js");
const getRealValidate = memoize(
/**
* @returns {function(Configuration | Configuration[]): void} validate fn
* @returns {(configuration: Configuration | Configuration[]) => void} validate fn
*/
() => {
const validateSchema = require("./validateSchema");

View File

@ -36,7 +36,7 @@ const deprecatedGetInitFragments = util.deprecate(
* @returns {InitFragment<GenerateContext>[]} init fragments
*/
(template, dependency, templateContext) =>
/** @type {DependencyTemplate & { getInitFragments: function(Dependency, DependencyTemplateContext): InitFragment<GenerateContext>[] }} */
/** @type {DependencyTemplate & { getInitFragments: (dependency: Dependency, dependencyTemplateContext: DependencyTemplateContext) => InitFragment<GenerateContext>[] }} */
(template).getInitFragments(dependency, templateContext),
"DependencyTemplate.getInitFragment is deprecated (use apply(dep, source, { initFragments }) instead)",
"DEP_WEBPACK_JAVASCRIPT_GENERATOR_GET_INIT_FRAGMENTS"

View File

@ -1000,7 +1000,7 @@ class JavascriptModulesPlugin {
const lastEntryModule =
/** @type {Module} */
(last(chunkGraph.getChunkEntryModulesIterable(chunk)));
/** @type {function(string[], string): Source} */
/** @type {(content: string[], name: string) => Source} */
const toSource = useSourceMap
? (content, name) =>
new OriginalSource(Template.asString(content), name)

View File

@ -94,8 +94,8 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
/** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[] }} GetInfoResult */
/** @typedef {Statement | ModuleDeclaration | Expression} StatementPathItem */
/** @typedef {function(string): void} OnIdentString */
/** @typedef {function(string, Identifier): void} OnIdent */
/** @typedef {(ident: string) => void} OnIdentString */
/** @typedef {(ident: string, identifier: Identifier) => void} OnIdent */
/** @typedef {StatementPathItem[]} StatementPath */
// TODO remove cast when @types/estree has been updated to import assertions
@ -1361,7 +1361,7 @@ class JavascriptParser extends Parser {
});
/**
* @param {"Identifier" | "ThisExpression" | "MemberExpression"} exprType expression type name
* @param {function(Expression | SpreadElement): GetInfoResult | undefined} getInfo get info
* @param {(node: Expression | SpreadElement) => GetInfoResult | undefined} getInfo get info
* @returns {void}
*/
const tapEvaluateWithVariableInfo = (exprType, getInfo) => {
@ -3637,13 +3637,13 @@ class JavascriptParser extends Parser {
expression.callee.type === "MemberExpression" &&
expression.callee.object.type.endsWith("FunctionExpression") &&
!expression.callee.computed &&
// eslint-disable-next-line no-warning-comments
// @ts-ignore
// TODO check me and handle more cases
(expression.callee.property.name === "call" ||
// eslint-disable-next-line no-warning-comments
// @ts-ignore
expression.callee.property.name === "bind") &&
/** @type {boolean} */
(
/** @type {TODO} */
(expression.callee.property).name === "call" ||
/** @type {TODO} */
(expression.callee.property).name === "bind"
) &&
expression.arguments.length > 0 &&
isSimpleFunction(
/** @type {FunctionExpression | ArrowFunctionExpression} */
@ -3881,8 +3881,8 @@ class JavascriptParser extends Parser {
* @template R
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
* @param {Expression | Super} expr expression info
* @param {(function(string, string | ScopeInfo | VariableInfo, function(): string[]): any) | undefined} fallback callback when variable in not handled by hooks
* @param {(function(string): any) | undefined} defined callback when variable is defined
* @param {((name: string, rootInfo: string | ScopeInfo | VariableInfo, getMembers: () => string[]) => any) | undefined} fallback callback when variable in not handled by hooks
* @param {((result?: string) => any) | undefined} defined callback when variable is defined
* @param {AsArray<T>} args args for the hook
* @returns {R | undefined} result of hook
*/
@ -3933,7 +3933,7 @@ class JavascriptParser extends Parser {
* @template R
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks that should be called
* @param {ExportedVariableInfo} info variable info
* @param {AsArray<T>} args args for the hook
* @param {AsArray<T>} args args for the hook
* @returns {R | undefined} result of hook
*/
callHooksForInfo(hookMap, info, ...args) {
@ -3951,8 +3951,8 @@ class JavascriptParser extends Parser {
* @template R
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
* @param {ExportedVariableInfo} info variable info
* @param {(function(string): any) | undefined} fallback callback when variable in not handled by hooks
* @param {(function(string=): any) | undefined} defined callback when variable is defined
* @param {((name: string) => any) | undefined} fallback callback when variable in not handled by hooks
* @param {((result?: string) => any) | undefined} defined callback when variable is defined
* @param {AsArray<T>} args args for the hook
* @returns {R | undefined} result of hook
*/
@ -4001,8 +4001,8 @@ class JavascriptParser extends Parser {
* @template R
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
* @param {string} name key in map
* @param {(function(string): any) | undefined} fallback callback when variable in not handled by hooks
* @param {(function(): any) | undefined} defined callback when variable is defined
* @param {((value: string) => any) | undefined} fallback callback when variable in not handled by hooks
* @param {(() => any) | undefined} defined callback when variable is defined
* @param {AsArray<T>} args args for the hook
* @returns {R | undefined} result of hook
*/
@ -4019,7 +4019,7 @@ class JavascriptParser extends Parser {
/**
* @deprecated
* @param {(string | Pattern | Property)[]} params scope params
* @param {function(): void} fn inner function
* @param {() => void} fn inner function
* @returns {void}
*/
inScope(params, fn) {
@ -4049,7 +4049,7 @@ class JavascriptParser extends Parser {
/**
* @param {boolean} state executed state
* @param {function(): void} fn inner function
* @param {() => void} fn inner function
*/
inExecutedPath(state, fn) {
const oldState = this.scope.inExecutedPath;
@ -4067,7 +4067,7 @@ class JavascriptParser extends Parser {
/**
* @param {boolean} hasThis true, when this is defined
* @param {Identifier[]} params scope params
* @param {function(): void} fn inner function
* @param {() => void} fn inner function
* @returns {void}
*/
inClassScope(hasThis, params, fn) {
@ -4100,7 +4100,7 @@ class JavascriptParser extends Parser {
/**
* @param {boolean} hasThis true, when this is defined
* @param {(Pattern | string)[]} params scope params
* @param {function(): void} fn inner function
* @param {() => void} fn inner function
* @returns {void}
*/
inFunctionScope(hasThis, params, fn) {
@ -4131,7 +4131,7 @@ class JavascriptParser extends Parser {
}
/**
* @param {function(): void} fn inner function
* @param {() => void} fn inner function
* @param {boolean} inExecutedPath executed state
* @returns {void}
*/

View File

@ -19,13 +19,14 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
* @param {JavascriptParser} parser the parser
* @param {string} value the const value
* @param {(string[] | null)=} runtimeRequirements runtime requirements
* @returns {function(Expression): true} plugin function
* @returns {(expression: Expression) => true} plugin function
*/
module.exports.toConstantDependency = (parser, value, runtimeRequirements) =>
function constDependency(expr) {
const dep = new ConstDependency(
value,
/** @type {Range} */ (expr.range),
/** @type {Range} */
(expr.range),
runtimeRequirements
);
dep.loc = /** @type {SourceLocation} */ (expr.loc);
@ -35,7 +36,7 @@ module.exports.toConstantDependency = (parser, value, runtimeRequirements) =>
/**
* @param {string} value the string value
* @returns {function(Expression): BasicEvaluatedExpression} plugin function
* @returns {(expression: Expression) => BasicEvaluatedExpression} plugin function
*/
module.exports.evaluateToString = value =>
function stringExpression(expr) {
@ -46,7 +47,7 @@ module.exports.evaluateToString = value =>
/**
* @param {number} value the number value
* @returns {function(Expression): BasicEvaluatedExpression} plugin function
* @returns {(expression: Expression) => BasicEvaluatedExpression} plugin function
*/
module.exports.evaluateToNumber = value =>
function stringExpression(expr) {
@ -57,7 +58,7 @@ module.exports.evaluateToNumber = value =>
/**
* @param {boolean} value the boolean value
* @returns {function(Expression): BasicEvaluatedExpression} plugin function
* @returns {(expression: Expression) => BasicEvaluatedExpression} plugin function
*/
module.exports.evaluateToBoolean = value =>
function booleanExpression(expr) {
@ -69,9 +70,9 @@ module.exports.evaluateToBoolean = value =>
/**
* @param {string} identifier identifier
* @param {string} rootInfo rootInfo
* @param {function(): string[]} getMembers getMembers
* @param {boolean|null=} truthy is truthy, null if nullish
* @returns {function(Expression): BasicEvaluatedExpression} callback
* @param {() => string[]} getMembers getMembers
* @param {boolean | null=} truthy is truthy, null if nullish
* @returns {(expression: Expression) => BasicEvaluatedExpression} callback
*/
module.exports.evaluateToIdentifier = (
identifier,
@ -102,7 +103,7 @@ module.exports.evaluateToIdentifier = (
/**
* @param {JavascriptParser} parser the parser
* @param {string} message the message
* @returns {function(Expression): boolean | undefined} callback to handle unsupported expression
* @returns {(expression: Expression) => boolean | undefined} callback to handle unsupported expression
*/
module.exports.expressionIsUnsupported = (parser, message) =>
function unsupportedExpression(expr) {

View File

@ -165,7 +165,7 @@ module.exports.updateHashForEntryStartup = (
/**
* @param {Chunk} chunk the chunk
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {function(Chunk, ChunkGraph): boolean} filterFn filter function
* @param {(chunk: Chunk, chunkGraph: ChunkGraph) => boolean} filterFn filter function
* @returns {Set<number | string>} initially fulfilled chunk ids
*/
module.exports.getInitialChunkIds = (chunk, chunkGraph, filterFn) => {

View File

@ -37,8 +37,8 @@ const TIMERS_AGGREGATES_SYMBOL = Symbol("webpack logger aggregated times");
class WebpackLogger {
/**
* @param {function(LogTypeEnum, EXPECTED_ANY[]=): void} log log function
* @param {function(string | function(): string): WebpackLogger} getChildLogger function to create child logger
* @param {(type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} log log function
* @param {(name: string | (() => string)) => WebpackLogger} getChildLogger function to create child logger
*/
constructor(log, getChildLogger) {
this[LOG_SYMBOL] = log;

View File

@ -11,13 +11,13 @@ const { LogType } = require("./Logger");
/** @typedef {import("../../declarations/WebpackOptions").FilterTypes} FilterTypes */
/** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */
/** @typedef {function(string): boolean} FilterFunction */
/** @typedef {function(string, LogTypeEnum, EXPECTED_ANY[]=): void} LoggingFunction */
/** @typedef {(item: string) => boolean} FilterFunction */
/** @typedef {(value: string, type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} LoggingFunction */
/**
* @typedef {object} LoggerConsole
* @property {function(): void} clear
* @property {function(): void} trace
* @property {() => void} clear
* @property {() => void} trace
* @property {(...args: EXPECTED_ANY[]) => void} info
* @property {(...args: EXPECTED_ANY[]) => void} log
* @property {(...args: EXPECTED_ANY[]) => void} warn

View File

@ -69,7 +69,7 @@ module.exports = ({ colors, appendOnly, stream }) => {
* @param {string} prefix prefix
* @param {string} colorPrefix color prefix
* @param {string} colorSuffix color suffix
* @returns {(function(...EXPECTED_ANY[]): void)} function to write with colors
* @returns {(...args: EXPECTED_ANY[]) => void} function to write with colors
*/
const writeColored =
(prefix, colorPrefix, colorSuffix) =>

View File

@ -44,7 +44,7 @@ const moveModuleBetween = (chunkGraph, oldChunk, newChunk) => module => {
/**
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {Chunk} chunk the chunk
* @returns {function(Module): boolean} filter for entry module
* @returns {(module: Module) => boolean} filter for entry module
*/
const isNotAEntryModule = (chunkGraph, chunk) => module =>
!chunkGraph.isEntryModuleInChunk(module, chunk);

View File

@ -60,6 +60,7 @@ const {
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
/** @typedef {import("../Module").BuildCallback} BuildCallback */
/** @typedef {import("../Module").BuildInfo} BuildInfo */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
@ -745,7 +746,7 @@ class ConcatenatedModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {
@ -1418,7 +1419,7 @@ class ConcatenatedModule extends Module {
}
// Map with all root exposed used exports
/** @type {Map<string, function(RequestShortener): string>} */
/** @type {Map<string, (requestShortener: RequestShortener) => string>} */
const exportsMap = new Map();
// Set with all root exposed unused exports

View File

@ -9,6 +9,7 @@ const { UsageState } = require("../ExportsInfo");
/** @typedef {import("estree").Node} AnyNode */
/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
@ -18,7 +19,7 @@ const { UsageState } = require("../ExportsInfo");
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
/** @typedef {Map<TopLevelSymbol | null, Set<string | TopLevelSymbol> | true | undefined>} InnerGraph */
/** @typedef {function(boolean | Set<string> | undefined): void} UsageCallback */
/** @typedef {(value: boolean | Set<string> | undefined) => void} UsageCallback */
/**
* @typedef {object} StateObject
@ -314,7 +315,7 @@ module.exports.isDependencyUsedByExports = (
* @param {Dependency} dependency the dependency
* @param {Set<string> | boolean | undefined} usedByExports usedByExports info
* @param {ModuleGraph} moduleGraph moduleGraph
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
* @returns {null | false | GetConditionFn} function to determine if the connection is active
*/
module.exports.getDependencyUsedByExportsCondition = (
dependency,

View File

@ -101,7 +101,7 @@ class ModuleConcatenationPlugin {
/**
* @param {Module} module the module
* @param {Module | function(RequestShortener): string} problem the problem
* @param {Module | ((requestShortener: RequestShortener) => string)} problem the problem
* @returns {(requestShortener: RequestShortener) => string} the reason
*/
const formatBailoutWarning = (module, problem) => requestShortener => {
@ -543,11 +543,11 @@ class ModuleConcatenationPlugin {
* @param {RuntimeSpec} activeRuntime the runtime scope of the root module
* @param {Set<Module>} possibleModules modules that are candidates
* @param {Set<Module>} candidates list of potential candidates (will be added to)
* @param {Map<Module, Module | function(RequestShortener): string>} failureCache cache for problematic modules to be more performant
* @param {Map<Module, Module | ((requestShortener: RequestShortener) => string)>} failureCache cache for problematic modules to be more performant
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {boolean} avoidMutateOnFailure avoid mutating the config when adding fails
* @param {Statistics} statistics gathering metrics
* @returns {null | Module | function(RequestShortener): string} the problematic module
* @returns {null | Module | ((requestShortener: RequestShortener) => string)} the problematic module
*/
_tryToAdd(
compilation,
@ -846,6 +846,8 @@ class ModuleConcatenationPlugin {
}
}
/** @typedef {Module | ((requestShortener: RequestShortener) => string)} Problem */
class ConcatConfiguration {
/**
* @param {Module} rootModule the root module
@ -857,7 +859,7 @@ class ConcatConfiguration {
/** @type {Set<Module>} */
this.modules = new Set();
this.modules.add(rootModule);
/** @type {Map<Module, Module | function(RequestShortener): string>} */
/** @type {Map<Module, Problem>} */
this.warnings = new Map();
}
@ -882,14 +884,14 @@ class ConcatConfiguration {
/**
* @param {Module} module the module
* @param {Module | function(RequestShortener): string} problem the problem
* @param {Problem} problem the problem
*/
addWarning(module, problem) {
this.warnings.set(module, problem);
}
/**
* @returns {Map<Module, Module | function(RequestShortener): string>} warnings
* @returns {Map<Module, Problem>} warnings
*/
getWarningsSorted() {
return new Map(

View File

@ -38,7 +38,7 @@ const addToList = (itemOrItems, list) => {
/**
* @template T
* @param {T[]} input list
* @param {function(T): Buffer} fn map function
* @param {(item: T) => Buffer} fn map function
* @returns {Buffer[]} buffers without duplicates
*/
const mapAndDeduplicateBuffers = (input, fn) => {

View File

@ -167,7 +167,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
const defaultGetName = /** @type {GetName} */ (() => {});
const deterministicGroupingForModules =
/** @type {function(DeterministicGroupingOptionsForModule): DeterministicGroupingGroupedItemsForModule[]} */
/** @type {(options: DeterministicGroupingOptionsForModule) => DeterministicGroupingGroupedItemsForModule[]} */
(deterministicGrouping);
/** @type {WeakMap<Module, string>} */
@ -451,7 +451,7 @@ const normalizeCacheGroups = (cacheGroups, defaultSizeTypes) => {
return cacheGroups;
}
if (typeof cacheGroups === "object" && cacheGroups !== null) {
/** @type {(function(Module, CacheGroupsContext, CacheGroupSource[]): void)[]} */
/** @type {((module: Module, context: CacheGroupsContext, results: CacheGroupSource[]) => void)[]} */
const handlers = [];
for (const key of Object.keys(cacheGroups)) {
const option = cacheGroups[key];

View File

@ -10,7 +10,7 @@ const { SyncHook } = require("tapable");
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRules} RuleSetRules */
/** @typedef {function(string | EffectData): boolean} RuleConditionFunction */
/** @typedef {(value: string | EffectData) => boolean} RuleConditionFunction */
/**
* @typedef {object} RuleCondition
@ -32,7 +32,7 @@ const { SyncHook } = require("tapable");
/**
* @typedef {object} CompiledRule
* @property {RuleCondition[]} conditions
* @property {(Effect|function(EffectData): Effect[])[]} effects
* @property {(Effect | ((effectData: EffectData) => Effect[]))[]} effects
* @property {CompiledRule[]=} rules
* @property {CompiledRule[]=} oneOf
*/
@ -46,10 +46,10 @@ const { SyncHook } = require("tapable");
/**
* @typedef {object} RuleSet
* @property {Map<string, any>} references map of references in the rule set (may grow over time)
* @property {function(EffectData): Effect[]} exec execute the rule set
* @property {(effectData: EffectData) => Effect[]} exec execute the rule set
*/
/** @typedef {{ apply: (function(RuleSetCompiler): void) }} RuleSetPlugin */
/** @typedef {{ apply: (ruleSetCompiler: RuleSetCompiler) => void }} RuleSetPlugin */
class RuleSetCompiler {
/**

View File

@ -52,7 +52,7 @@ class UseEffectRulePlugin {
* @param {string} path options path
* @param {string} defaultIdent default ident when none is provided
* @param {object} item user provided use value
* @returns {Effect|function(any): Effect[]} effect
* @returns {Effect | ((value: TODO) => Effect[])} effect
*/
const useToEffect = (path, defaultIdent, item) => {
if (typeof item === "function") {
@ -104,7 +104,7 @@ class UseEffectRulePlugin {
/**
* @param {string} path options path
* @param {any} items user provided use value
* @param {TODO} items user provided use value
* @returns {Effect[]} effects
*/
const useToEffectsWithoutIdent = (path, items) => {
@ -120,8 +120,8 @@ class UseEffectRulePlugin {
/**
* @param {string} path current path
* @param {any} items user provided use value
* @returns {(Effect|function(any): Effect[])[]} effects
* @param {TODO} items user provided use value
* @returns {(Effect | ((value: TODO) => Effect[]))[]} effects
*/
const useToEffects = (path, items) => {
if (Array.isArray(items)) {

View File

@ -20,7 +20,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
* @param {string} contentType the contentType to use the content hash for
* @param {string} name kind of filename
* @param {string} global function name to be assigned
* @param {function(Chunk): TemplatePath | false} getFilenameForChunk functor to get the filename or function
* @param {(chunk: Chunk) => TemplatePath | false} getFilenameForChunk functor to get the filename or function
* @param {boolean} allChunks when false, only async chunks are included
*/
constructor(contentType, name, global, getFilenameForChunk, allChunks) {
@ -138,7 +138,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
};
/**
* @param {string} value string
* @returns {function(number): string} string to put in quotes with length
* @returns {(length: number) => string} string to put in quotes with length
*/
const unquotedStringifyWithLength = value => length =>
unquotedStringify(`${value}`.slice(0, length));
@ -191,7 +191,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
}
/**
* @param {function(Chunk): string | number} fn function from chunk to value
* @param {(chunk: Chunk) => string | number} fn function from chunk to value
* @returns {string} code with static mapping of results of fn
*/
const createMap = fn => {
@ -225,14 +225,14 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
};
/**
* @param {function(Chunk): string | number} fn function from chunk to value
* @param {(chunk: Chunk) => string | number} fn function from chunk to value
* @returns {string} code with static mapping of results of fn for including in quoted string
*/
const mapExpr = fn => `" + ${createMap(fn)} + "`;
/**
* @param {function(Chunk): string | number} fn function from chunk to value
* @returns {function(number): string} function which generates code with static mapping of results of fn for including in quoted string for specific length
* @param {(chunk: Chunk) => string | number} fn function from chunk to value
* @returns {(length: number) => string} function which generates code with static mapping of results of fn for including in quoted string for specific length
*/
const mapExprWithLength = fn => length =>
`" + ${createMap(c => `${fn(c)}`.slice(0, length))} + "`;

View File

@ -32,7 +32,7 @@ const getHttps = memoize(() => require("https"));
/**
* @param {typeof import("http") | typeof import("https")} request request
* @param {string | { toString: () => string } | undefined} proxy proxy
* @returns {function(URL, RequestOptions, function(IncomingMessage): void): EventEmitter} fn
* @returns {(url: URL, requestOptions: RequestOptions, callback: (incomingMessage: IncomingMessage) => void) => EventEmitter} fn
*/
const proxyFetch = (request, proxy) => (url, options, callback) => {
const eventEmitter = new EventEmitter();
@ -255,8 +255,18 @@ class Lockfile {
/**
* @template R
* @param {function(function(Error | null, R=): void): void} fn function
* @returns {function(function(Error | null, R=): void): void} cached function
* @typedef {(err: Error | null, result?: R) => void} FnWithoutKeyCallback
*/
/**
* @template R
* @typedef {(callback: FnWithoutKeyCallback<R>) => void} FnWithoutKey
*/
/**
* @template R
* @param {FnWithoutKey<R>} fn function
* @returns {FnWithoutKey<R>} cached function
*/
const cachedWithoutKey = fn => {
let inFlight = false;
@ -264,7 +274,7 @@ const cachedWithoutKey = fn => {
let cachedError;
/** @type {R | undefined} */
let cachedResult;
/** @type {(function(Error| null, R=): void)[] | undefined} */
/** @type {FnWithoutKeyCallback<R>[] | undefined} */
let cachedCallbacks;
return callback => {
if (inFlight) {
@ -286,23 +296,34 @@ const cachedWithoutKey = fn => {
};
};
/**
* @template R
* @typedef {(err: Error | null, result?: R) => void} FnWithKeyCallback
*/
/**
* @template T
* @template R
* @param {function(T, function(Error | null, R=): void): void} fn function
* @param {function(T, function(Error | null, R=): void): void=} forceFn function for the second try
* @returns {(function(T, function(Error | null, R=): void): void) & { force: function(T, function(Error | null, R=): void): void }} cached function
* @typedef {(item: T, callback: FnWithKeyCallback<R>) => void} FnWithKey
*/
/**
* @template T
* @template R
* @param {FnWithKey<T, R>} fn function
* @param {FnWithKey<T, R>=} forceFn function for the second try
* @returns {(FnWithKey<T, R>) & { force: FnWithKey<T, R> }} cached function
*/
const cachedWithKey = (fn, forceFn = fn) => {
/**
* @template R
* @typedef {{ result?: R, error?: Error, callbacks?: (function(Error | null, R=): void)[], force?: true }} CacheEntry
* @typedef {{ result?: R, error?: Error, callbacks?: FnWithKeyCallback<R>[], force?: true }} CacheEntry
*/
/** @type {Map<T, CacheEntry<R>>} */
const cache = new Map();
/**
* @param {T} arg arg
* @param {function(Error | null, R=): void} callback callback
* @param {FnWithKeyCallback<R>} callback callback
* @returns {void}
*/
const resultFn = (arg, callback) => {
@ -333,7 +354,7 @@ const cachedWithKey = (fn, forceFn = fn) => {
};
/**
* @param {T} arg arg
* @param {function(Error | null, R=): void} callback callback
* @param {FnWithKeyCallback<R>} callback callback
* @returns {void}
*/
resultFn.force = (arg, callback) => {
@ -487,7 +508,7 @@ class HttpUriPlugin {
const getLockfile = cachedWithoutKey(
/**
* @param {function(Error | null, Lockfile=): void} callback callback
* @param {(err: Error | null, lockfile?: Lockfile) => void} callback callback
* @returns {void}
*/
callback => {
@ -581,7 +602,7 @@ class HttpUriPlugin {
* @param {Lockfile} lockfile lockfile
* @param {string} url url
* @param {ResolveContentResult} result result
* @param {function(Error | null, ResolveContentResult=): void} callback callback
* @param {(err: Error | null, result?: ResolveContentResult) => void} callback callback
* @returns {void}
*/
const storeResult = (lockfile, url, result, callback) => {
@ -608,7 +629,7 @@ class HttpUriPlugin {
/**
* @param {string} url URL
* @param {string | null} integrity integrity
* @param {function(Error | null, ResolveContentResult=): void} callback callback
* @param {(err: Error | null, resolveContentResult?: ResolveContentResult) => void} callback callback
*/
const resolveContent = (url, integrity, callback) => {
/**
@ -654,7 +675,7 @@ class HttpUriPlugin {
/**
* @param {string} url URL
* @param {FetchResult | RedirectFetchResult | undefined} cachedResult result from cache
* @param {function(Error | null, FetchResult=): void} callback callback
* @param {(err: Error | null, fetchResult?: FetchResult) => void} callback callback
* @returns {void}
*/
const fetchContentRaw = (url, cachedResult, callback) => {
@ -826,7 +847,7 @@ class HttpUriPlugin {
const fetchContent = cachedWithKey(
/**
* @param {string} url URL
* @param {function(Error | null, { validUntil: number, etag?: string, entry: LockfileEntry, content: Buffer, fresh: boolean } | { validUntil: number, etag?: string, location: string, fresh: boolean }=): void} callback callback
* @param {(err: Error | null, result?: { validUntil: number, etag?: string, entry: LockfileEntry, content: Buffer, fresh: boolean } | { validUntil: number, etag?: string, location: string, fresh: boolean }) => void} callback callback
* @returns {void}
*/
(url, callback) => {
@ -864,7 +885,7 @@ class HttpUriPlugin {
const getInfo = cachedWithKey(
/**
* @param {string} url the url
* @param {function(Error | null, Info=): void} callback callback
* @param {(err: Error | null, info?: Info) => void} callback callback
* @returns {void}
*/
// eslint-disable-next-line no-loop-func
@ -1113,7 +1134,7 @@ Run build with un-frozen lockfile to automatically fix lockfile.`
/**
* @param {URL} url url
* @param {ResourceDataWithData} resourceData resource data
* @param {function(Error | null, true | void): void} callback callback
* @param {(err: Error | null, result: true | void) => void} callback callback
*/
const respondWithUrlModule = (url, resourceData, callback) => {
getInfo(url.href, (err, _result) => {

View File

@ -64,7 +64,7 @@ const hashForName = (buffers, hashFunction) => {
const COMPRESSION_CHUNK_SIZE = 100 * 1024 * 1024;
const DECOMPRESSION_CHUNK_SIZE = 100 * 1024 * 1024;
/** @type {function(Buffer, number, number): void} */
/** @type {(buffer: Buffer, value: number, offset: number) => void} */
const writeUInt64LE = Buffer.prototype.writeBigUInt64LE
? (buf, value, offset) => {
buf.writeBigUInt64LE(BigInt(value), offset);
@ -76,7 +76,7 @@ const writeUInt64LE = Buffer.prototype.writeBigUInt64LE
buf.writeUInt32LE(high, offset + 4);
};
/** @type {function(Buffer, number): void} */
/** @type {(buffer: Buffer, offset: number) => void} */
const readUInt64LE = Buffer.prototype.readBigUInt64LE
? (buf, offset) => Number(buf.readBigUInt64LE(offset))
: (buf, offset) => {
@ -98,7 +98,7 @@ const readUInt64LE = Buffer.prototype.readBigUInt64LE
* @param {FileMiddleware} middleware this
* @param {BufferSerializableType[] | Promise<BufferSerializableType[]>} data data to be serialized
* @param {string | boolean} name file base name
* @param {function(string | false, Buffer[], number): Promise<void>} writeFile writes a file
* @param {(name: string | false, buffers: Buffer[], size: number) => Promise<void>} writeFile writes a file
* @param {string | Hash} hashFunction hash function to use
* @returns {Promise<SerializeResult>} resulting file pointer and promise
*/
@ -248,7 +248,7 @@ const serialize = async (
/**
* @param {FileMiddleware} middleware this
* @param {string | false} name filename
* @param {function(string | false): Promise<Buffer[]>} readFile read content of a file
* @param {(name: string | false) => Promise<Buffer[]>} readFile read content of a file
* @returns {Promise<BufferSerializableType[]>} deserialized data
*/
const deserialize = async (middleware, name, readFile) => {

View File

@ -61,24 +61,24 @@ Technically any value can be used.
/**
* @typedef {object} ObjectSerializerContext
* @property {function(any): void} write
* @property {function(any): void} setCircularReference
* @property {function(): ObjectSerializerSnapshot} snapshot
* @property {function(ObjectSerializerSnapshot): void} rollback
* @property {(function(any): void)=} writeLazy
* @property {(function(any, object=): (() => Promise<any> | any))=} writeSeparate
* @property {(value: any) => void} write
* @property {(value: any) => void} setCircularReference
* @property {() => ObjectSerializerSnapshot} snapshot
* @property {(snapshot: ObjectSerializerSnapshot) => void} rollback
* @property {((item: any) => void)=} writeLazy
* @property {((item: any, obj?: object) => (() => Promise<any> | any))=} writeSeparate
*/
/**
* @typedef {object} ObjectDeserializerContext
* @property {function(): any} read
* @property {function(any): void} setCircularReference
* @property {() => any} read
* @property {(value: any) => void} setCircularReference
*/
/**
* @typedef {object} ObjectSerializer
* @property {function(any, ObjectSerializerContext): void} serialize
* @property {function(ObjectDeserializerContext): any} deserialize
* @property {(value: any, context: ObjectSerializerContext) => void} serialize
* @property {(context: ObjectDeserializerContext) => any} deserialize
*/
/**
@ -201,7 +201,7 @@ const loaders = new Map();
*/
class ObjectMiddleware extends SerializerMiddleware {
/**
* @param {function(ObjectSerializerContext | ObjectDeserializerContext): void} extendContext context extensions
* @param {(context: ObjectSerializerContext | ObjectDeserializerContext) => void} extendContext context extensions
* @param {string | Hash} hashFunction hash function to use
*/
constructor(extendContext, hashFunction = "md4") {
@ -212,7 +212,7 @@ class ObjectMiddleware extends SerializerMiddleware {
/**
* @param {RegExp} regExp RegExp for which the request is tested
* @param {function(string): boolean} loader loader to load the request, returns true when successful
* @param {(request: string) => boolean} loader loader to load the request, returns true when successful
* @returns {void}
*/
static registerLoader(regExp, loader) {

View File

@ -13,7 +13,7 @@ const LAZY_SERIALIZED_VALUE = Symbol("lazy serialization data");
/**
* @template LazyResult
* @typedef {function(): LazyResult | Promise<LazyResult>} InternalLazyFunction
* @typedef {() => LazyResult | Promise<LazyResult>} InternalLazyFunction
*/
/** @typedef {Record<string, any>} LazyOptions */
@ -115,7 +115,7 @@ class SerializerMiddleware {
/**
* @template LazyResult, R
* @param {LazyFunction<LazyResult>} lazy lazy function
* @param {function(LazyResult): Promise<R> | R} serialize serialize function
* @param {(lazyResult: LazyResult) => Promise<R> | R} serialize serialize function
* @returns {LazyFunction<R>} new lazy
*/
static serializeLazy(lazy, serialize) {
@ -143,7 +143,7 @@ class SerializerMiddleware {
/**
* @template LazyResult, R
* @param {LazyFunction<LazyResult>} lazy lazy function
* @param {function(LazyResult): Promise<R> | R} deserialize deserialize function
* @param {(lazyResult: LazyResult) => Promise<R> | R} deserialize deserialize function
* @returns {LazyFunction<R>} new lazy
*/
static deserializeLazy(lazy, deserialize) {

View File

@ -22,9 +22,11 @@ const ConsumeSharedFallbackDependency = require("./ConsumeSharedFallbackDependen
/** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
/** @typedef {import("../Module").BuildCallback} BuildCallback */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
/** @typedef {import("../RequestShortener")} RequestShortener */
@ -115,7 +117,7 @@ class ConsumeSharedModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -127,7 +129,7 @@ class ConsumeSharedModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -18,9 +18,11 @@ const ProvideForSharedDependency = require("./ProvideForSharedDependency");
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module").BuildCallback} BuildCallback */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
/** @typedef {import("../RequestShortener")} RequestShortener */
@ -77,7 +79,7 @@ class ProvideSharedModule extends Module {
/**
* @param {NeedBuildContext} context context info
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
@ -89,7 +91,7 @@ class ProvideSharedModule extends Module {
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {function(WebpackError=): void} callback callback function
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {

View File

@ -8,18 +8,20 @@
const ModuleFactory = require("../ModuleFactory");
const ProvideSharedModule = require("./ProvideSharedModule");
/** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
/** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("../ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
/** @typedef {import("./ProvideSharedDependency")} ProvideSharedDependency */
class ProvideSharedModuleFactory extends ModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @param {ModuleFactoryCallback} callback callback
* @returns {void}
*/
create(data, callback) {
const dep = /** @type {ProvideSharedDependency} */ (data.dependencies[0]);
const dep =
/** @type {ProvideSharedDependency} */
(data.dependencies[0]);
callback(null, {
module: new ProvideSharedModule(
dep.shareScope,

View File

@ -326,8 +326,8 @@ module.exports.normalizeVersion = normalizeVersion;
* @param {InputFileSystem} fs file system
* @param {string} directory directory to start looking into
* @param {string[]} descriptionFiles possible description filenames
* @param {function((Error | null)=, DescriptionFile=, string[]=): void} callback callback
* @param {function(DescriptionFile=): boolean} satisfiesDescriptionFileData file data compliance check
* @param {(err?: Error | null, descriptionFile?: DescriptionFile, paths?: string[]) => void} callback callback
* @param {(descriptionFile?: DescriptionFile) => boolean} satisfiesDescriptionFileData file data compliance check
* @param {Set<string>} checkedFilePaths set of file paths that have been checked
*/
const getDescriptionFile = (

View File

@ -328,7 +328,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @template T
* @template I
* @param {Iterable<T>} items items to select from
* @param {function(T): Iterable<I>} selector selector function to select values from item
* @param {(item: T) => Iterable<I>} selector selector function to select values from item
* @returns {I[]} array of values
*/
const uniqueArray = (items, selector) => {
@ -346,7 +346,7 @@ const uniqueArray = (items, selector) => {
* @template T
* @template I
* @param {Iterable<T>} items items to select from
* @param {function(T): Iterable<I>} selector selector function to select values from item
* @param {(item: T) => Iterable<I>} selector selector function to select values from item
* @param {Comparator<I>} comparator comparator function
* @returns {I[]} array of values
*/
@ -375,7 +375,7 @@ const mapObject = (obj, fn) => {
/**
* @param {Compilation} compilation the compilation
* @param {function(Compilation, string): any[]} getItems get items
* @param {(compilation: Compilation, name: string) => any[]} getItems get items
* @returns {number} total number
*/
const countWithChildren = (compilation, getItems) => {
@ -2152,7 +2152,7 @@ const ASSETS_GROUPERS = {
/** @typedef {Record<string, (groupConfigs: GroupConfig<KnownStatsModule, TODO>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>} ModulesGroupers */
/** @type {function("module" | "chunk" | "root-of-chunk" | "nested"): ModulesGroupers} */
/** @type {(type: "module" | "chunk" | "root-of-chunk" | "nested") => ModulesGroupers} */
const MODULES_GROUPERS = type => ({
_: (groupConfigs, context, options) => {
/**
@ -2369,7 +2369,7 @@ const sortOrderRegular = field => {
/**
* @template T
* @param {string} field field name
* @returns {function(T, T): 0 | 1 | -1} comparators
* @returns {(a: T, b: T) => 0 | 1 | -1} comparators
*/
const sortByField = field => {
if (!field) {
@ -2436,7 +2436,7 @@ const RESULT_SORTERS = {
/**
* @param {Record<string, Record<string, Function>>} config the config see above
* @param {NormalizedStatsOptions} options stats options
* @param {function(string, Function): void} fn handler function called for every active line in config
* @param {(hookFor: string, fn: Function) => void} fn handler function called for every active line in config
* @returns {void}
*/
const iterateConfig = (config, options, fn) => {

View File

@ -274,8 +274,8 @@ const DEFAULTS = {
};
/**
* @param {string | ({ test: function(string): boolean }) | (function(string): boolean) | boolean} item item to normalize
* @returns {(function(string): boolean) | undefined} normalize fn
* @param {string | ({ test: (value: string) => boolean }) | ((value: string) => boolean) | boolean} item item to normalize
* @returns {((value: string) => boolean) | undefined} normalize fn
*/
const normalizeFilter = item => {
if (typeof item === "string") {
@ -295,7 +295,7 @@ const normalizeFilter = item => {
}
};
/** @type {Record<string, function(any): any[]>} */
/** @type {Record<string, (value: any) => any[]>} */
const NORMALIZER = {
excludeModules: value => {
if (!Array.isArray(value)) {

View File

@ -79,7 +79,7 @@ const getModuleName = name => {
/**
* @param {string} str string
* @param {function(string): string} fn function to apply to each line
* @param {(item: string) => string} fn function to apply to each line
* @returns {string} joined string
*/
const mapLines = (str, fn) => str.split("\n").map(fn).join("\n");
@ -726,7 +726,7 @@ const MODULE_TRACE_DEPENDENCY_PRINTERS = {
"moduleTraceDependency.loc": loc => loc
};
/** @type {Record<string, string | function(any): string>} */
/** @type {Record<string, string | ((item: any) => string)>} */
const ITEM_NAMES = {
"compilation.assets[]": "asset",
"compilation.modules[]": "module",
@ -969,7 +969,7 @@ const itemsJoinComma = items => items.filter(Boolean).join(", ");
/** @type {SimpleItemsJoiner} */
const itemsJoinCommaBrackets = items =>
items.length > 0 ? `(${items.filter(Boolean).join(", ")})` : undefined;
/** @type {function(string): SimpleItemsJoiner} */
/** @type {(item: string) => SimpleItemsJoiner} */
const itemsJoinCommaBracketsWithName = name => items =>
items.length > 0
? `(${name}: ${items.filter(Boolean).join(", ")})`
@ -1300,7 +1300,7 @@ const AVAILABLE_COLORS = {
magenta: "\u001B[1m\u001B[35m"
};
/** @type {Record<string, function(any, Required<KnownStatsPrinterColorFn> & StatsPrinterContext, ...any): string>} */
/** @type {Record<string, (value: any, options: Required<KnownStatsPrinterColorFn> & StatsPrinterContext, ...args: any) => string>} */
const AVAILABLE_FORMATS = {
formatChunkId: (id, { yellow }, direction) => {
switch (direction) {
@ -1391,7 +1391,7 @@ const AVAILABLE_FORMATS = {
}
};
/** @typedef {function(string): string} ResultModifierFn */
/** @typedef {(result: string) => string} ResultModifierFn */
/** @type {Record<string, ResultModifierFn>} */
const RESULT_MODIFIER = {
"module.modules": result => indent(result, "| ")

View File

@ -21,14 +21,14 @@ const smartGrouping = require("../util/smartGrouping");
/**
* @typedef {object} KnownStatsFactoryContext
* @property {string} type
* @property {function(string): string} makePathsRelative
* @property {(path: string) => string} makePathsRelative
* @property {Compilation} compilation
* @property {Set<Module>} rootModules
* @property {Map<string,Chunk[]>} compilationFileToChunks
* @property {Map<string,Chunk[]>} compilationAuxiliaryFileToChunks
* @property {Map<string, Chunk[]>} compilationFileToChunks
* @property {Map<string, Chunk[]>} compilationAuxiliaryFileToChunks
* @property {RuntimeSpec} runtime
* @property {function(Compilation): WebpackError[]} cachedGetErrors
* @property {function(Compilation): WebpackError[]} cachedGetWarnings
* @property {(compilation: Compilation) => WebpackError[]} cachedGetErrors
* @property {(compilation: Compilation) => WebpackError[]} cachedGetWarnings
*/
/** @typedef {Record<string, any> & KnownStatsFactoryContext} StatsFactoryContext */
@ -128,7 +128,7 @@ class StatsFactory {
* @param {HM} hookMap hook map
* @param {Caches<H>} cache cache
* @param {string} type type
* @param {function(H): R | void} fn fn
* @param {(hook: H) => R | void} fn fn
* @returns {R | void} hook
* @private
*/
@ -146,7 +146,7 @@ class StatsFactory {
* @param {Caches<H>} cache cache
* @param {string} type type
* @param {FactoryData} data data
* @param {function(H, FactoryData): FactoryData} fn fn
* @param {(hook: H, factoryData: FactoryData) => FactoryData} fn fn
* @returns {FactoryData} data
* @private
*/
@ -165,7 +165,7 @@ class StatsFactory {
* @param {Caches<H>} cache cache
* @param {string} type type
* @param {Array<FactoryData>} items items
* @param {function(H, R, number, number): R | undefined} fn fn
* @param {(hook: H, item: R, idx: number, i: number) => R | undefined} fn fn
* @param {boolean} forceClone force clone
* @returns {R[]} result for each level
* @private

View File

@ -147,7 +147,7 @@ class StatsPrinter {
* @template {H extends import("tapable").Hook<any, infer R> ? R : never} R
* @param {HM} hookMap hook map
* @param {string} type type
* @param {function(H): R | void} fn fn
* @param {(hooK: H) => R | void} fn fn
* @returns {R | void} hook
*/
_forEachLevel(hookMap, type, fn) {
@ -165,7 +165,7 @@ class StatsPrinter {
* @param {HM} hookMap hook map
* @param {string} type type
* @param {string} data data
* @param {function(H, string): string} fn fn
* @param {(hook: H, data: string) => string} fn fn
* @returns {string} result of `fn`
*/
_forEachLevelWaterfall(hookMap, type, data, fn) {

View File

@ -10,7 +10,7 @@
*/
class ArrayQueue {
/**
* @param {Iterable<T>=} items The initial elements.
* @param {Iterable<T>} [items] The initial elements.
*/
constructor(items) {
/**

View File

@ -50,12 +50,12 @@ class AsyncQueueEntry {
/**
* @template T, K
* @typedef {function(T): K} getKey
* @typedef {(item: T) => K} getKey
*/
/**
* @template T, R
* @typedef {function(T, Callback<R>): void} Processor
* @typedef {(item: T, callback: Callback<R>) => void} Processor
*/
/**

View File

@ -19,7 +19,7 @@ const last = set => {
/**
* @template T
* @param {Iterable<T>} iterable iterable
* @param {function(T): boolean | null | undefined} filter predicate
* @param {(value: T) => boolean | null | undefined} filter predicate
* @returns {boolean} true, if some items match the filter predicate
*/
const someInIterable = (iterable, filter) => {

View File

@ -15,7 +15,7 @@ const SortableSet = require("./SortableSet");
/**
* @template T
* @typedef {(function(T): any) | (function(any, any): number)} Arg
* @typedef {((value: T) => any) | ((value: any, value1: any) => number)} Arg
*/
/**
@ -32,9 +32,9 @@ const SortableSet = require("./SortableSet");
*/
class LazyBucketSortedSet {
/**
* @param {function(T): K} getKey function to get key from item
* @param {function(K, K): number} comparator comparator to sort keys
* @param {...Arg<T>} args more pairs of getKey and comparator plus optional final comparator for the last layer
* @param {(item: T) => K} getKey function to get key from item
* @param {(a: K, b: K) => number} comparator comparator to sort keys
* @param {...Arg<T>} args more pairs of getKey and comparator plus optional final comparator for the last layer
*/
constructor(getKey, comparator, ...args) {
this._getKey = getKey;
@ -142,7 +142,7 @@ class LazyBucketSortedSet {
/**
* @param {T} item to be updated item
* @returns {function(true=): void} finish update
* @returns {(remove?: true) => void} finish update
*/
startUpdate(item) {
if (this._unsortedItems.has(item)) {

View File

@ -149,7 +149,7 @@ class LazySet {
/**
* @template K
* @param {function(T, T, Set<T>): void} callbackFn function called for each entry
* @param {(value: T, value2: T, set: Set<T>) => void} callbackFn function called for each entry
* @param {K} thisArg this argument for the callbackFn
* @returns {void}
*/

Some files were not shown because too many files have changed in this diff Show More