Skip to content

Commit 8614c75

Browse files
committed
run inherit types tool on existing code
1 parent 0e6d505 commit 8614c75

12 files changed

+95
-8
lines changed

lib/DelegatedModule.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDepende
1212
const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDependency");
1313

1414
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
15+
/** @typedef {import("./util/createHash").Hash} Hash */
1516

1617
class DelegatedModule extends Module {
1718
constructor(sourceRequest, data, type, userRequest, originalRequest) {
@@ -99,6 +100,10 @@ class DelegatedModule extends Module {
99100
return 42;
100101
}
101102

103+
/**
104+
* @param {Hash} hash the hash used to track dependencies
105+
* @returns {void}
106+
*/
102107
updateHash(hash) {
103108
hash.update(this.type);
104109
hash.update(JSON.stringify(this.request));

lib/DependenciesBlock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class DependenciesBlock {
7373
}
7474

7575
/**
76-
* @param {Hash} hash the hash used to track dependencies, from "crypto" module
76+
* @param {Hash} hash the hash used to track dependencies
7777
* @returns {void}
7878
*/
7979
updateHash(hash) {

lib/DllModule.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
const { RawSource } = require("webpack-sources");
88
const Module = require("./Module");
99

10+
/** @typedef {import("./util/createHash").Hash} Hash */
11+
1012
class DllModule extends Module {
1113
constructor(context, dependencies, name, type) {
1214
super("javascript/dynamic", context);
@@ -44,6 +46,10 @@ class DllModule extends Module {
4446
return 12;
4547
}
4648

49+
/**
50+
* @param {Hash} hash the hash used to track dependencies
51+
* @returns {void}
52+
*/
4753
updateHash(hash) {
4854
hash.update("dll module");
4955
hash.update(this.name || "");

lib/ExternalModule.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const Module = require("./Module");
99
const WebpackMissingModule = require("./dependencies/WebpackMissingModule");
1010
const Template = require("./Template");
1111

12+
/** @typedef {import("./util/createHash").Hash} Hash */
13+
1214
class ExternalModule extends Module {
1315
constructor(request, type, userRequest) {
1416
super("javascript/dynamic", null);
@@ -148,6 +150,10 @@ class ExternalModule extends Module {
148150
return 42;
149151
}
150152

153+
/**
154+
* @param {Hash} hash the hash used to track dependencies
155+
* @returns {void}
156+
*/
151157
updateHash(hash) {
152158
hash.update(this.externalType);
153159
hash.update(JSON.stringify(this.request));

lib/Generator.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*/
55
"use strict";
66

7-
/** @typedef {import("./Module")} Module */
7+
/** @typedef {import("./NormalModule")} NormalModule */
88
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
99
/** @typedef {import("webpack-sources").Source} Source */
10+
/** @typedef {import("./Dependency").DependencyTemplate} DependencyTemplate */
1011

1112
/**
1213
*
@@ -18,8 +19,8 @@ class Generator {
1819

1920
/**
2021
* @abstract
21-
* @param {Module} module module for which the code should be generated
22-
* @param {Map<Function, TODO>} dependencyTemplates mapping from dependencies to templates
22+
* @param {NormalModule} module module for which the code should be generated
23+
* @param {Map<Function, DependencyTemplate>} dependencyTemplates mapping from dependencies to templates
2324
* @param {RuntimeTemplate} runtimeTemplate the runtime template
2425
* @param {string} type which kind of code should be generated
2526
* @returns {Source} generated code
@@ -35,6 +36,13 @@ class ByTypeGenerator extends Generator {
3536
this.map = map;
3637
}
3738

39+
/**
40+
* @param {NormalModule} module module for which the code should be generated
41+
* @param {Map<Function, DependencyTemplate>} dependencyTemplates mapping from dependencies to templates
42+
* @param {RuntimeTemplate} runtimeTemplate the runtime template
43+
* @param {string} type which kind of code should be generated
44+
* @returns {Source} generated code
45+
*/
3846
generate(module, dependencyTemplates, runtimeTemplate, type) {
3947
const generator = this.map[type];
4048
if (!generator) {

lib/Module.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const Template = require("./Template");
1414
/** @typedef {import("./Chunk")} Chunk */
1515
/** @typedef {import("./RequestShortener")} RequestShortener */
1616
/** @typedef {import("./WebpackError")} WebpackError */
17+
/** @typedef {import("./util/createHash").Hash} Hash */
1718

1819
const EMPTY_RESOLVE_OPTIONS = {};
1920

@@ -298,6 +299,10 @@ class Module extends DependenciesBlock {
298299
return true;
299300
}
300301

302+
/**
303+
* @param {Hash} hash the hash used to track dependencies
304+
* @returns {void}
305+
*/
301306
updateHash(hash) {
302307
hash.update(`${this.id}`);
303308
hash.update(JSON.stringify(this.usedExports));

lib/MultiModule.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const Module = require("./Module");
88
const Template = require("./Template");
99
const { RawSource } = require("webpack-sources");
1010

11+
/** @typedef {import("./util/createHash").Hash} Hash */
12+
1113
class MultiModule extends Module {
1214
constructor(context, dependencies, name) {
1315
super("javascript/dynamic", context);
@@ -45,6 +47,10 @@ class MultiModule extends Module {
4547
return 16 + this.dependencies.length * 12;
4648
}
4749

50+
/**
51+
* @param {Hash} hash the hash used to track dependencies
52+
* @returns {void}
53+
*/
4854
updateHash(hash) {
4955
hash.update("multi module");
5056
hash.update(this.name || "");

lib/NormalModule.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const ModuleWarning = require("./ModuleWarning");
2424
const createHash = require("./util/createHash");
2525
const contextify = require("./util/identifier").contextify;
2626

27+
/** @typedef {import("./util/createHash").Hash} Hash */
28+
2729
const asString = buf => {
2830
if (Buffer.isBuffer(buf)) {
2931
return buf.toString("utf-8");
@@ -527,6 +529,10 @@ class NormalModule extends Module {
527529
return this._source ? this._source.size() : -1;
528530
}
529531

532+
/**
533+
* @param {Hash} hash the hash used to track dependencies
534+
* @returns {void}
535+
*/
530536
updateHash(hash) {
531537
hash.update(this._buildHash);
532538
super.updateHash(hash);

lib/RuntimeTemplate.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
const Template = require("./Template");
88

9+
/** @typedef {import("./Module")} Module */
10+
911
module.exports = class RuntimeTemplate {
1012
constructor(outputOptions, requestShortener) {
1113
this.outputOptions = outputOptions || {};
@@ -188,6 +190,16 @@ module.exports = class RuntimeTemplate {
188190
return `${promise || "Promise.resolve()"}.then(${getModuleFunction})`;
189191
}
190192

193+
/**
194+
*
195+
* @param {Object} options options object
196+
* @param {boolean=} options.update whether a new variable should be created or the existing one updated
197+
* @param {Module} options.module the module
198+
* @param {string} options.request the request that should be printed as comment
199+
* @param {string} options.importVar name of the import variable
200+
* @param {Module} options.originModule module in which the statement is emitted
201+
* @returns {string} the import statement
202+
*/
191203
importStatement({ update, module, request, importVar, originModule }) {
192204
if (!module) {
193205
return this.missingModuleStatement({

lib/optimize/ConcatenatedModule.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const createHash = require("../util/createHash");
2121

2222
/** @typedef {import("../Dependency")} Dependency */
2323
/** @typedef {import("../Compilation")} Compilation */
24+
/** @typedef {import("../util/createHash").Hash} Hash */
2425

2526
/**
2627
* @typedef {Object} ConcatenationEntry
@@ -1180,6 +1181,10 @@ class ConcatenatedModule extends Module {
11801181
return nameWithNumber;
11811182
}
11821183

1184+
/**
1185+
* @param {Hash} hash the hash used to track dependencies
1186+
* @returns {void}
1187+
*/
11831188
updateHash(hash) {
11841189
for (const info of this._orderedConcatenationList) {
11851190
switch (info.type) {

0 commit comments

Comments
 (0)