add more types

This commit is contained in:
Ivan Kopeykin 2020-08-02 21:09:36 +03:00
parent a14f073b35
commit 4fc44a3398
27 changed files with 115 additions and 62 deletions

View File

@ -8,6 +8,7 @@
const util = require("util"); const util = require("util");
const memorize = require("./util/memorize"); const memorize = require("./util/memorize");
/** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */
/** @typedef {import("./Compilation")} Compilation */ /** @typedef {import("./Compilation")} Compilation */
const getJavascriptModulesPlugin = memorize(() => const getJavascriptModulesPlugin = memorize(() =>
@ -17,7 +18,7 @@ const getJavascriptModulesPlugin = memorize(() =>
// TODO webpack 6 remove this class // TODO webpack 6 remove this class
class ChunkTemplate { class ChunkTemplate {
/** /**
* @param {TODO} outputOptions TODO * @param {OutputOptions} outputOptions output options
* @param {Compilation} compilation the compilation * @param {Compilation} compilation the compilation
*/ */
constructor(outputOptions, compilation) { constructor(outputOptions, compilation) {
@ -124,7 +125,7 @@ Object.defineProperty(ChunkTemplate.prototype, "outputOptions", {
get: util.deprecate( get: util.deprecate(
/** /**
* @this {ChunkTemplate} * @this {ChunkTemplate}
* @returns {TODO} output options * @returns {OutputOptions} output options
*/ */
function () { function () {
return this._outputOptions; return this._outputOptions;

View File

@ -14,6 +14,8 @@ const ConcatenatedModule = require("./optimize/ConcatenatedModule");
const { absolutify } = require("./util/identifier"); const { absolutify } = require("./util/identifier");
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/WebpackOptions").DevTool} DevToolOptions */
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @type {WeakMap<Source, Source>} */ /** @type {WeakMap<Source, Source>} */
@ -31,13 +33,17 @@ const devtoolWarning = new RawSource(`/*
class EvalSourceMapDevToolPlugin { class EvalSourceMapDevToolPlugin {
/** /**
* @param {TODO} options Options object * @param {SourceMapDevToolPluginOptions|string} inputOptions Options object
*/ */
constructor(options = {}) { constructor(inputOptions) {
if (typeof options === "string") { /** @type {SourceMapDevToolPluginOptions} */
let options;
if (typeof inputOptions === "string") {
options = { options = {
append: options append: inputOptions
}; };
} else {
options = inputOptions;
} }
this.sourceMapComment = this.sourceMapComment =
options.append || "//# sourceURL=[module]\n//# sourceMappingURL=[url]"; options.append || "//# sourceURL=[module]\n//# sourceMappingURL=[url]";

View File

@ -12,6 +12,7 @@ const memorize = require("./util/memorize");
/** @typedef {import("webpack-sources").ConcatSource} ConcatSource */ /** @typedef {import("webpack-sources").ConcatSource} ConcatSource */
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */
/** @typedef {import("./ModuleTemplate")} ModuleTemplate */ /** @typedef {import("./ModuleTemplate")} ModuleTemplate */
/** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./Compilation")} Compilation */ /** @typedef {import("./Compilation")} Compilation */
@ -37,11 +38,11 @@ const getJsonpTemplatePlugin = memorize(() =>
class MainTemplate { class MainTemplate {
/** /**
* *
* @param {TODO} outputOptions output options for the MainTemplate * @param {OutputOptions} outputOptions output options for the MainTemplate
* @param {Compilation} compilation the compilation * @param {Compilation} compilation the compilation
*/ */
constructor(outputOptions, compilation) { constructor(outputOptions, compilation) {
/** @type {TODO} */ /** @type {OutputOptions} */
this._outputOptions = outputOptions || {}; this._outputOptions = outputOptions || {};
this.hooks = Object.freeze({ this.hooks = Object.freeze({
renderManifest: { renderManifest: {
@ -311,7 +312,7 @@ Object.defineProperty(MainTemplate.prototype, "outputOptions", {
get: util.deprecate( get: util.deprecate(
/** /**
* @this {MainTemplate} * @this {MainTemplate}
* @returns {TODO} output options * @returns {OutputOptions} output options
*/ */
function () { function () {
return this._outputOptions; return this._outputOptions;

View File

@ -14,6 +14,7 @@ const { compareChunksById } = require("./util/comparators");
const makeSerializable = require("./util/makeSerializable"); const makeSerializable = require("./util/makeSerializable");
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
/** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./ChunkGroup")} ChunkGroup */ /** @typedef {import("./ChunkGroup")} ChunkGroup */
@ -112,7 +113,7 @@ class Module extends DependenciesBlock {
this.debugId = debugId++; this.debugId = debugId++;
// Info from Factory // Info from Factory
/** @type {TODO} */ /** @type {ResolveOptions} */
this.resolveOptions = EMPTY_RESOLVE_OPTIONS; this.resolveOptions = EMPTY_RESOLVE_OPTIONS;
/** @type {object | undefined} */ /** @type {object | undefined} */
this.factoryMeta = undefined; this.factoryMeta = undefined;
@ -597,8 +598,8 @@ class Module extends DependenciesBlock {
/** /**
* @deprecated Use needBuild instead * @deprecated Use needBuild instead
* @param {TODO} fileTimestamps timestamps of files * @param {Map<string, number|null>} fileTimestamps timestamps of files
* @param {TODO} contextTimestamps timestamps of directories * @param {Map<string, number|null>} contextTimestamps timestamps of directories
* @returns {boolean} true, if the module needs a rebuild * @returns {boolean} true, if the module needs a rebuild
*/ */
needRebuild(fileTimestamps, contextTimestamps) { needRebuild(fileTimestamps, contextTimestamps) {

View File

@ -12,7 +12,7 @@ const makeSerializable = require("./util/makeSerializable");
class ModuleBuildError extends WebpackError { class ModuleBuildError extends WebpackError {
/** /**
* @param {string | Error&any} err error thrown * @param {string | Error&any} err error thrown
* @param {TODO} info additional info * @param {{from?: string|null}} info additional info
*/ */
constructor(err, { from = null } = {}) { constructor(err, { from = null } = {}) {
let message = "Module build failed"; let message = "Module build failed";

View File

@ -7,6 +7,7 @@
const WebpackError = require("./WebpackError"); const WebpackError = require("./WebpackError");
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./Module")} Module */ /** @typedef {import("./Module")} Module */
class ModuleDependencyError extends WebpackError { class ModuleDependencyError extends WebpackError {
@ -14,7 +15,7 @@ class ModuleDependencyError extends WebpackError {
* Creates an instance of ModuleDependencyError. * Creates an instance of ModuleDependencyError.
* @param {Module} module module tied to dependency * @param {Module} module module tied to dependency
* @param {Error} err error thrown * @param {Error} err error thrown
* @param {TODO} loc location of dependency * @param {DependencyLocation} loc location of dependency
*/ */
constructor(module, err, loc) { constructor(module, err, loc) {
super(err.message); super(err.message);

View File

@ -7,13 +7,14 @@
const WebpackError = require("./WebpackError"); const WebpackError = require("./WebpackError");
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./Module")} Module */ /** @typedef {import("./Module")} Module */
module.exports = class ModuleDependencyWarning extends WebpackError { module.exports = class ModuleDependencyWarning extends WebpackError {
/** /**
* @param {Module} module module tied to dependency * @param {Module} module module tied to dependency
* @param {Error} err error thrown * @param {Error} err error thrown
* @param {TODO} loc location of dependency * @param {DependencyLocation} loc location of dependency
*/ */
constructor(module, err, loc) { constructor(module, err, loc) {
super(err.message); super(err.message);

View File

@ -12,7 +12,7 @@ const makeSerializable = require("./util/makeSerializable");
class ModuleError extends WebpackError { class ModuleError extends WebpackError {
/** /**
* @param {Error} err error thrown * @param {Error} err error thrown
* @param {TODO} info additional info * @param {{from?: string|null}} info additional info
*/ */
constructor(err, { from = null } = {}) { constructor(err, { from = null } = {}) {
let message = "Module Error"; let message = "Module Error";

View File

@ -7,6 +7,7 @@
const WebpackError = require("./WebpackError"); const WebpackError = require("./WebpackError");
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./Module")} Module */ /** @typedef {import("./Module")} Module */
const previouslyPolyfilledBuiltinModules = { const previouslyPolyfilledBuiltinModules = {
@ -44,7 +45,7 @@ class ModuleNotFoundError extends WebpackError {
/** /**
* @param {Module} module module tied to dependency * @param {Module} module module tied to dependency
* @param {Error&any} err error thrown * @param {Error&any} err error thrown
* @param {TODO} loc location of dependency * @param {DependencyLocation} loc location of dependency
*/ */
constructor(module, err, loc) { constructor(module, err, loc) {
let message = `Module not found: ${err.toString()}`; let message = `Module not found: ${err.toString()}`;

View File

@ -12,7 +12,7 @@ const makeSerializable = require("./util/makeSerializable");
class ModuleWarning extends WebpackError { class ModuleWarning extends WebpackError {
/** /**
* @param {Error} warning error thrown * @param {Error} warning error thrown
* @param {TODO} info additional info * @param {{from?: string|null}} info additional info
*/ */
constructor(warning, { from = null } = {}) { constructor(warning, { from = null } = {}) {
let message = "Module Warning"; let message = "Module Warning";

View File

@ -729,7 +729,7 @@ class NormalModule extends Module {
const hash = createHash(compilation.outputOptions.hashFunction); const hash = createHash(compilation.outputOptions.hashFunction);
if (this._source) { if (this._source) {
hash.update("source"); hash.update("source");
this._source.updateHash(/** @type {TODO} */ (hash)); this._source.updateHash(hash);
} }
hash.update("meta"); hash.update("meta");
hash.update(JSON.stringify(this.buildMeta)); hash.update(JSON.stringify(this.buildMeta));

View File

@ -32,6 +32,7 @@ const { parseResource } = require("./util/identifier");
/** @typedef {import("./Generator")} Generator */ /** @typedef {import("./Generator")} Generator */
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */ /** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */ /** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
/** @typedef {import("./Parser")} Parser */
/** @typedef {import("./ResolverFactory")} ResolverFactory */ /** @typedef {import("./ResolverFactory")} ResolverFactory */
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */ /** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
@ -748,6 +749,11 @@ class NormalModuleFactory extends ModuleFactory {
return parser; return parser;
} }
/**
* @param {string} type type
* @param {{[k: string]: any}} parserOptions parser options
* @returns {Parser} parser
*/
createParser(type, parserOptions = {}) { createParser(type, parserOptions = {}) {
const parser = this.hooks.createParser.for(type).call(parserOptions); const parser = this.hooks.createParser.for(type).call(parserOptions);
if (!parser) { if (!parser) {

View File

@ -15,7 +15,7 @@
* @property {NormalModule} current * @property {NormalModule} current
* @property {NormalModule} module * @property {NormalModule} module
* @property {Compilation} compilation * @property {Compilation} compilation
* @property {TODO} options * @property {{[k: string]: any}} options
*/ */
/** @typedef {Record<string, any> & ParserStateBase} ParserState */ /** @typedef {Record<string, any> & ParserStateBase} ParserState */

View File

@ -11,6 +11,7 @@ const { compareIds } = require("./util/comparators");
/** @typedef {import("webpack-sources").ConcatSource} ConcatSource */ /** @typedef {import("webpack-sources").ConcatSource} ConcatSource */
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */
/** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./ChunkGraph")} ChunkGraph */ /** @typedef {import("./ChunkGraph")} ChunkGraph */
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */ /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
@ -44,7 +45,7 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
* @property {Chunk} chunk the chunk used to render * @property {Chunk} chunk the chunk used to render
* @property {string} hash * @property {string} hash
* @property {string} fullHash * @property {string} fullHash
* @property {TODO} outputOptions * @property {OutputOptions} outputOptions
* @property {CodeGenerationResults} codeGenerationResults * @property {CodeGenerationResults} codeGenerationResults
* @property {{javascript: ModuleTemplate}} moduleTemplates * @property {{javascript: ModuleTemplate}} moduleTemplates
* @property {DependencyTemplates} dependencyTemplates * @property {DependencyTemplates} dependencyTemplates

View File

@ -19,7 +19,7 @@ const NullDependency = require("./NullDependency");
class ConstDependency extends NullDependency { class ConstDependency extends NullDependency {
/** /**
* @param {string} expression the expression * @param {string} expression the expression
* @param {TODO} range the source range * @param {number|[number, number]} range the source range
* @param {string[]=} runtimeRequirements runtime requirements * @param {string[]=} runtimeRequirements runtime requirements
*/ */
constructor(expression, range, runtimeRequirements) { constructor(expression, range, runtimeRequirements) {

View File

@ -7,6 +7,8 @@
const { parseResource } = require("../util/identifier"); const { parseResource } = require("../util/identifier");
/** @typedef {import("estree").Node} EsTreeNode */
/** @typedef {import("../../declarations/WebpackOptions").ModuleOptions} ModuleOptions */
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("./ContextDependency")} ContextDependency */ /** @typedef {import("./ContextDependency")} ContextDependency */
@ -34,8 +36,7 @@ const splitContextFromPrefix = prefix => {
}; };
}; };
// TODO Use Omit<> type for contextOptions when typescript >= 3.5 /** @typedef {Partial<Omit<ContextDependencyOptions, "resource"|"recursive"|"regExp">>} PartialContextDependencyOptions */
/** @typedef {Partial<Pick<ContextDependencyOptions, Exclude<keyof ContextDependencyOptions, "resource"|"recursive"|"regExp">>>} PartialContextDependencyOptions */
/** @typedef {{ new(options: ContextDependencyOptions, range: [number, number], valueRange: [number, number]): ContextDependency }} ContextDependencyConstructor */ /** @typedef {{ new(options: ContextDependencyOptions, range: [number, number], valueRange: [number, number]): ContextDependency }} ContextDependencyConstructor */
@ -43,8 +44,8 @@ const splitContextFromPrefix = prefix => {
* @param {ContextDependencyConstructor} Dep the Dependency class * @param {ContextDependencyConstructor} Dep the Dependency class
* @param {[number, number]} range source range * @param {[number, number]} range source range
* @param {BasicEvaluatedExpression} param context param * @param {BasicEvaluatedExpression} param context param
* @param {TODO} expr the AST expression * @param {EsTreeNode} expr expr
* @param {TODO} options options for context creation * @param {ModuleOptions} options options for context creation
* @param {PartialContextDependencyOptions} contextOptions options for the ContextModule * @param {PartialContextDependencyOptions} contextOptions options for the ContextModule
* @param {JavascriptParser} parser the parser * @param {JavascriptParser} parser the parser
* @returns {ContextDependency} the created Dependency * @returns {ContextDependency} the created Dependency
@ -209,7 +210,7 @@ exports.create = (Dep, range, param, expr, options, contextOptions, parser) => {
{ {
request: options.exprContextRequest, request: options.exprContextRequest,
recursive: options.exprContextRecursive, recursive: options.exprContextRecursive,
regExp: options.exprContextRegExp, regExp: /** @type {RegExp} */ (options.exprContextRegExp),
mode: "sync", mode: "sync",
...contextOptions ...contextOptions
}, },

View File

@ -135,7 +135,7 @@ const EMPTY_COMMENT_OPTIONS = {
class JavascriptParser extends Parser { class JavascriptParser extends Parser {
/** /**
* @param {TODO} options options * @param {{[k: string]: any}} options options
* @param {"module" | "script" | "auto"} sourceType default source type * @param {"module" | "script" | "auto"} sourceType default source type
*/ */
constructor(options, sourceType = "auto") { constructor(options, sourceType = "auto") {

View File

@ -7,6 +7,7 @@
const Watchpack = require("watchpack"); const Watchpack = require("watchpack");
/** @typedef {import("../../declarations/WebpackOptions").WatchOptions} WatchOptions */
/** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */ /** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
/** @typedef {import("../util/fs").WatchFileSystem} WatchFileSystem */ /** @typedef {import("../util/fs").WatchFileSystem} WatchFileSystem */
/** @typedef {import("../util/fs").WatchMethod} WatchMethod */ /** @typedef {import("../util/fs").WatchMethod} WatchMethod */
@ -26,7 +27,7 @@ class NodeWatchFileSystem {
* @param {Iterable<string>} directories watched directories * @param {Iterable<string>} directories watched directories
* @param {Iterable<string>} missing watched exitance entries * @param {Iterable<string>} missing watched exitance entries
* @param {number} startTime timestamp of start time * @param {number} startTime timestamp of start time
* @param {TODO} options options object * @param {WatchOptions} options options object
* @param {function(Error=, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback * @param {function(Error=, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback
* @param {function(string, number): void} callbackUndelayed callback when the first change was detected * @param {function(string, number): void} callbackUndelayed callback when the first change was detected
* @returns {Watcher} a watcher * @returns {Watcher} a watcher

View File

@ -31,6 +31,7 @@ const contextify = require("../util/identifier").contextify;
const makeSerializable = require("../util/makeSerializable"); const makeSerializable = require("../util/makeSerializable");
const propertyAccess = require("../util/propertyAccess"); const propertyAccess = require("../util/propertyAccess");
/** @typedef {import("eslint-scope").Scope} Scope */
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
/** @typedef {import("../ChunkGraph")} ChunkGraph */ /** @typedef {import("../ChunkGraph")} ChunkGraph */
@ -77,8 +78,8 @@ const propertyAccess = require("../util/propertyAccess");
* @property {Source} internalSource * @property {Source} internalSource
* @property {ReplaceSource} source * @property {ReplaceSource} source
* @property {Iterable<string>} runtimeRequirements * @property {Iterable<string>} runtimeRequirements
* @property {TODO} globalScope * @property {Scope} globalScope
* @property {TODO} moduleScope * @property {Scope} moduleScope
* @property {Map<string, string>} internalNames * @property {Map<string, string>} internalNames
* @property {Map<string, string>} exportMap * @property {Map<string, string>} exportMap
* @property {Map<string, ReexportInfo>} reexportMap * @property {Map<string, ReexportInfo>} reexportMap
@ -1060,11 +1061,17 @@ class ConcatenatedModule extends Module {
// renaming to work correctly // renaming to work correctly
for (const childScope of info.moduleScope.childScopes) { for (const childScope of info.moduleScope.childScopes) {
if (childScope.type !== "class") continue; if (childScope.type !== "class") continue;
if (!childScope.block.superClass) continue; const block = childScope.block;
superClassExpressions.push({ if (
range: childScope.block.superClass.range, (block.type === "ClassDeclaration" ||
variables: childScope.variables block.type === "ClassExpression") &&
}); block.superClass
) {
superClassExpressions.push({
range: block.superClass.range,
variables: childScope.variables
});
}
} }
} }

View File

@ -766,7 +766,7 @@ const SIMPLE_EXTRACTORS = {
}, },
moduleReason: { moduleReason: {
_: (object, reason, { runtime }, { requestShortener }) => { _: (object, reason, { runtime }, { requestShortener }) => {
const depAsAny = /** @type {TODO} */ (reason.dependency); const depAsAny = /** @type {Dependency|undefined} */ (reason.dependency);
Object.assign(object, { Object.assign(object, {
moduleIdentifier: reason.originModule moduleIdentifier: reason.originModule
? reason.originModule.identifier() ? reason.originModule.identifier()
@ -787,7 +787,9 @@ const SIMPLE_EXTRACTORS = {
active: reason.isActive(runtime), active: reason.isActive(runtime),
explanation: reason.explanation, explanation: reason.explanation,
userRequest: userRequest:
depAsAny && "userRequest" in depAsAny ? depAsAny.userRequest : null depAsAny && "userRequest" in depAsAny
? /** @type {{[k: string]: any}} */ (depAsAny).userRequest
: null
}); });
if (reason.dependency) { if (reason.dependency) {
const locInfo = formatLocation(reason.dependency.loc); const locInfo = formatLocation(reason.dependency.loc);

View File

@ -8,6 +8,7 @@
const path = require("path"); const path = require("path");
/** @typedef {import("fs").Stats} NodeFsStats */ /** @typedef {import("fs").Stats} NodeFsStats */
/** @typedef {import("../../declarations/WebpackOptions").WatchOptions} WatchOptions */
/** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */ /** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
/** @typedef {function(NodeJS.ErrnoException=): void} Callback */ /** @typedef {function(NodeJS.ErrnoException=): void} Callback */
@ -32,7 +33,7 @@ const path = require("path");
* @param {Iterable<string>} directories watched directories * @param {Iterable<string>} directories watched directories
* @param {Iterable<string>} missing watched exitance entries * @param {Iterable<string>} missing watched exitance entries
* @param {number} startTime timestamp of start time * @param {number} startTime timestamp of start time
* @param {TODO} options options object * @param {WatchOptions} options options object
* @param {function(Error=, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback * @param {function(Error=, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback
* @param {function(string, number): void} callbackUndelayed callback when the first change was detected * @param {function(string, number): void} callbackUndelayed callback when the first change was detected
* @returns {Watcher} a watcher * @returns {Watcher} a watcher

View File

@ -40,7 +40,7 @@ const validateSchema = (schema, options) => {
validate(schema, options, { validate(schema, options, {
name: "Webpack", name: "Webpack",
postFormatter: (formattedError, error) => { postFormatter: (formattedError, error) => {
const children = /** @type {TODO} */ (error).children; const children = error.children;
if ( if (
children && children &&
children.some( children.some(

View File

@ -58,7 +58,6 @@ class WasmFinalizeExportsPlugin {
) )
) { ) {
// 4. error // 4. error
/** @type {TODO} */
const error = new UnsupportedWebAssemblyFeatureError( const error = new UnsupportedWebAssemblyFeatureError(
`Export "${name}" with ${jsIncompatibleExports[name]} can only be used for direct wasm to wasm dependencies\n` + `Export "${name}" with ${jsIncompatibleExports[name]} can only be used for direct wasm to wasm dependencies\n` +
`It's used from ${connection.originModule.readableIdentifier( `It's used from ${connection.originModule.readableIdentifier(

View File

@ -15,6 +15,7 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency"); const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../Generator").GenerateContext} GenerateContext */ /** @typedef {import("../Generator").GenerateContext} GenerateContext */
/** @typedef {import("../NormalModule")} NormalModule */ /** @typedef {import("../NormalModule")} NormalModule */
@ -63,7 +64,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
const initParams = []; const initParams = [];
let index = 0; let index = 0;
for (const dep of module.dependencies) { for (const dep of module.dependencies) {
const depAsAny = /** @type {TODO} */ (dep); const depAsAny = /** @type {Dependency} */ (dep);
if (moduleGraph.getModule(dep)) { if (moduleGraph.getModule(dep)) {
let importData = importedModules.get(moduleGraph.getModule(dep)); let importData = importedModules.get(moduleGraph.getModule(dep));
if (importData === undefined) { if (importData === undefined) {
@ -73,7 +74,9 @@ class WebAssemblyJavascriptGenerator extends Generator {
importVar: `m${index}`, importVar: `m${index}`,
index, index,
request: request:
"userRequest" in depAsAny ? depAsAny.userRequest : undefined, "userRequest" in depAsAny
? /** @type {{[k: string]: any}} */ (depAsAny).userRequest
: undefined,
names: new Set(), names: new Set(),
reexports: [] reexports: []
}) })

View File

@ -5,6 +5,7 @@
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/eslint-scope": "^3.7.0",
"@types/estree": "^0.0.45", "@types/estree": "^0.0.45",
"@webassemblyjs/ast": "1.9.0", "@webassemblyjs/ast": "1.9.0",
"@webassemblyjs/helper-module-context": "1.9.0", "@webassemblyjs/helper-module-context": "1.9.0",

31
types.d.ts vendored
View File

@ -910,7 +910,7 @@ declare abstract class ChunkTemplate {
hash: { tap: (options?: any, fn?: any) => void }; hash: { tap: (options?: any, fn?: any) => void };
hashForChunk: { tap: (options?: any, fn?: any) => void }; hashForChunk: { tap: (options?: any, fn?: any) => void };
}>; }>;
readonly outputOptions: any; readonly outputOptions: Output;
} }
declare interface CodeGenerationContext { declare interface CodeGenerationContext {
/** /**
@ -2490,11 +2490,11 @@ declare class EvalDevToolModulePlugin {
apply(compiler: Compiler): void; apply(compiler: Compiler): void;
} }
declare class EvalSourceMapDevToolPlugin { declare class EvalSourceMapDevToolPlugin {
constructor(options?: any); constructor(inputOptions: string | SourceMapDevToolPluginOptions);
sourceMapComment: any; sourceMapComment: string;
moduleFilenameTemplate: any; moduleFilenameTemplate: DevtoolFallbackModuleFilenameTemplate;
namespace: any; namespace: string;
options: any; options: SourceMapDevToolPluginOptions;
/** /**
* Apply the plugin * Apply the plugin
@ -3477,7 +3477,7 @@ declare abstract class JavascriptParser extends Parser {
program: SyncBailHook<[Program, Comment[]], boolean | void>; program: SyncBailHook<[Program, Comment[]], boolean | void>;
finish: SyncBailHook<[Program, Comment[]], boolean | void>; finish: SyncBailHook<[Program, Comment[]], boolean | void>;
}>; }>;
options: any; options: { [index: string]: any };
sourceType: "module" | "script" | "auto"; sourceType: "module" | "script" | "auto";
scope: ScopeInfo; scope: ScopeInfo;
state: Record<string, any> & ParserStateBase; state: Record<string, any> & ParserStateBase;
@ -4049,7 +4049,7 @@ declare abstract class MainTemplate {
options?: any options?: any
) => { path: string; info: AssetInfo }; ) => { path: string; info: AssetInfo };
readonly requireFn: string; readonly requireFn: string;
readonly outputOptions: any; readonly outputOptions: Output;
} }
declare interface MapOptions { declare interface MapOptions {
columns?: boolean; columns?: boolean;
@ -4115,7 +4115,7 @@ declare class Module extends DependenciesBlock {
context: string; context: string;
needId: boolean; needId: boolean;
debugId: number; debugId: number;
resolveOptions: any; resolveOptions: ResolveOptionsWebpackOptions;
factoryMeta: any; factoryMeta: any;
buildMeta: KnownBuildMeta & Record<string, any>; buildMeta: KnownBuildMeta & Record<string, any>;
buildInfo: any; buildInfo: any;
@ -4183,7 +4183,10 @@ declare class Module extends DependenciesBlock {
context: NeedBuildContext, context: NeedBuildContext,
callback: (arg0: WebpackError, arg1: boolean) => void callback: (arg0: WebpackError, arg1: boolean) => void
): void; ): void;
needRebuild(fileTimestamps?: any, contextTimestamps?: any): boolean; needRebuild(
fileTimestamps: Map<string, number>,
contextTimestamps: Map<string, number>
): boolean;
invalidateBuild(): void; invalidateBuild(): void;
identifier(): string; identifier(): string;
readableIdentifier(requestShortener: RequestShortener): string; readableIdentifier(requestShortener: RequestShortener): string;
@ -4916,7 +4919,7 @@ declare abstract class NormalModuleFactory extends ModuleFactory {
callback?: any callback?: any
): any; ): any;
getParser(type?: any, parserOptions?: {}): any; getParser(type?: any, parserOptions?: {}): any;
createParser(type?: any, parserOptions?: {}): any; createParser(type: string, parserOptions?: { [index: string]: any }): Parser;
getGenerator(type?: any, generatorOptions?: {}): Generator; getGenerator(type?: any, generatorOptions?: {}): Generator;
createGenerator(type?: any, generatorOptions?: {}): any; createGenerator(type?: any, generatorOptions?: {}): any;
getResolver(type?: any, resolveOptions?: any): Resolver & WithOptions; getResolver(type?: any, resolveOptions?: any): Resolver & WithOptions;
@ -5747,7 +5750,7 @@ declare interface ParserStateBase {
current: NormalModule; current: NormalModule;
module: NormalModule; module: NormalModule;
compilation: Compilation; compilation: Compilation;
options: any; options: { [index: string]: any };
} }
declare interface PathData { declare interface PathData {
chunkGraph?: ChunkGraph; chunkGraph?: ChunkGraph;
@ -6162,7 +6165,7 @@ declare interface RenderManifestOptions {
chunk: Chunk; chunk: Chunk;
hash: string; hash: string;
fullHash: string; fullHash: string;
outputOptions: any; outputOptions: Output;
codeGenerationResults: CodeGenerationResults; codeGenerationResults: CodeGenerationResults;
moduleTemplates: { javascript: ModuleTemplate }; moduleTemplates: { javascript: ModuleTemplate };
dependencyTemplates: DependencyTemplates; dependencyTemplates: DependencyTemplates;
@ -8384,7 +8387,7 @@ declare interface WatchFileSystem {
directories: Iterable<string>, directories: Iterable<string>,
missing: Iterable<string>, missing: Iterable<string>,
startTime: number, startTime: number,
options: any, options: WatchOptions,
callback: ( callback: (
arg0: Error, arg0: Error,
arg1: Map<string, FileSystemInfoEntry>, arg1: Map<string, FileSystemInfoEntry>,

View File

@ -621,7 +621,23 @@
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
"@types/estree@^0.0.45": "@types/eslint-scope@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.0.tgz#4792816e31119ebd506902a482caec4951fabd86"
integrity sha512-O/ql2+rrCUe2W2rs7wMR+GqPRcgB6UiqN5RhrR5xruFlY7l9YLMn0ZkDzjoHLeiFkR8MCQZVudUuuvQ2BLC9Qw==
dependencies:
"@types/eslint" "*"
"@types/estree" "*"
"@types/eslint@*":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.2.0.tgz#eb5c5b575237334df24c53195e37b53d66478d7b"
integrity sha512-LpUXkr7fnmPXWGxB0ZuLEzNeTURuHPavkC5zuU4sg62/TgL5ZEjamr5Y8b6AftwHtx2bPJasI+CL0TT2JwQ7aA==
dependencies:
"@types/estree" "*"
"@types/json-schema" "*"
"@types/estree@*", "@types/estree@^0.0.45":
version "0.0.45" version "0.0.45"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.45.tgz#e9387572998e5ecdac221950dab3e8c3b16af884" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.45.tgz#e9387572998e5ecdac221950dab3e8c3b16af884"
integrity sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g== integrity sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g==
@ -666,10 +682,10 @@
jest-diff "^25.2.1" jest-diff "^25.2.1"
pretty-format "^25.2.1" pretty-format "^25.2.1"
"@types/json-schema@^7.0.3", "@types/json-schema@^7.0.4": "@types/json-schema@*", "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.4":
version "7.0.4" version "7.0.5"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.5.tgz#dcce4430e64b443ba8945f0290fb564ad5bac6dd"
integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA== integrity sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==
"@types/mkdirp@^0.5.2": "@types/mkdirp@^0.5.2":
version "0.5.2" version "0.5.2"