fix: replaced some TODO with correct types and fixed some runtime issue

This commit is contained in:
Emanuele Stoppa 2019-11-08 10:13:16 +00:00 committed by Tobias Koppers
parent 0ea81b542c
commit e607681277
5 changed files with 14 additions and 8 deletions

View File

@ -547,7 +547,7 @@ class Compilation {
/** @type {Map<Module, CodeGenerationResult>} */
this.codeGenerationResults = undefined;
/** @type {AsyncQueue<TODO, TODO, Module>} */
/** @type {AsyncQueue<FactorizeModuleOptions, string, Module>} */
this.factorizeQueue = new AsyncQueue({
name: "factorize",
parallelism: options.parallelism || 100,
@ -1724,8 +1724,8 @@ class Compilation {
processRuntimeRequirements(entrypoints) {
const { chunkGraph } = this;
const additionalModuleRuntimeRequirements = /** @type {TODO} */ (this.hooks
.additionalModuleRuntimeRequirements);
const additionalModuleRuntimeRequirements = this.hooks
.additionalModuleRuntimeRequirements;
const runtimeRequirementInModule = this.hooks.runtimeRequirementInModule;
for (const module of this.modules) {
if (chunkGraph.getNumberOfModuleChunks(module) > 0) {

View File

@ -281,7 +281,7 @@ module.exports = class MultiCompiler {
}
/**
* @param {WatchOptions[]} watchOptions the watcher's options
* @param {WatchOptions|WatchOptions[]} watchOptions the watcher's options
* @param {Callback<MultiStats>} handler signals when the call finishes
* @returns {MultiWatching} a compiler watcher
*/

View File

@ -175,10 +175,10 @@ class NormalModuleFactory extends ModuleFactory {
*/
this.generatorCache = new Map();
this.hooks.factorize.tapAsync(
/** @type {TODO} */ ({
{
name: "NormalModuleFactory",
stage: 100
}),
},
(resolveData, callback) => {
this.hooks.resolve.callAsync(resolveData, (err, result) => {
if (err) return callback(err);

View File

@ -483,7 +483,7 @@ class WebAssemblyGenerator extends Generator {
const newBuf = Buffer.from(newBin);
return new RawSource(/** @type {TODO} */ (newBuf));
return new RawSource(newBuf);
}
}

View File

@ -14,6 +14,9 @@ const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin");
const validateSchema = require("./validateSchema");
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Compiler").WatchOptions} WatchOptions */
/** @typedef {import("./MultiCompiler")} MultiCompiler */
/** @typedef {import("./MultiStats")} MultiStats */
/** @typedef {import("./Stats")} Stats */
@ -76,15 +79,18 @@ const createCompiler = options => {
*/
const webpack = (options, callback) => {
validateSchema(webpackOptionsSchema, options);
/** @type {TODO} */
/** @type {MultiCompiler|Compiler} */
let compiler;
let watch = false;
/** @type {WatchOptions|WatchOptions[]} */
let watchOptions;
if (Array.isArray(options)) {
/** @type {MultiCompiler} */
compiler = createMultiCompiler(options);
watch = options.some(options => options.watch);
watchOptions = options.map(options => options.watchOptions || {});
} else {
/** @type {Compiler} */
compiler = createCompiler(options);
watch = options.watch;
watchOptions = options.watchOptions || {};