Skip to content

Commit 8de3b9b

Browse files
committed
add types to Module
1 parent 2adf5c2 commit 8de3b9b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

lib/Module.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const ModuleReason = require("./ModuleReason");
1111
const SortableSet = require("./util/SortableSet");
1212
const Template = require("./Template");
1313

14+
/** @typedef {typeof import("./Chunk")} Chunk */
15+
16+
/** @typedef {typeof import("./RequestShortener")} RequestShortener */
17+
1418
const EMPTY_RESOLVE_OPTIONS = {};
1519

1620
let debugId = 1000;
@@ -23,51 +27,79 @@ const sortByDebugId = (a, b) => {
2327
return a.debugId - b.debugId;
2428
};
2529

30+
/** @typedef {(requestShortener: RequestShortener) => string} OptimizationBailoutFunction */
31+
2632
class Module extends DependenciesBlock {
2733
constructor(type, context = null) {
2834
super();
35+
/** @type {string} */
2936
this.type = type;
37+
/** @type {string} */
3038
this.context = context;
3139

3240
// Unique Id
41+
/** @type {number} */
3342
this.debugId = debugId++;
3443

3544
// Hash
45+
/** @type {string} */
3646
this.hash = undefined;
47+
/** @type {string} */
3748
this.renderedHash = undefined;
3849

3950
// Info from Factory
51+
/** @type {object} */
4052
this.resolveOptions = EMPTY_RESOLVE_OPTIONS;
53+
/** @type {object} */
4154
this.factoryMeta = {};
4255

4356
// Info from Build
57+
/** @type {Error[]} */
4458
this.warnings = [];
59+
/** @type {Error[]} */
4560
this.errors = [];
61+
/** @type {object} */
4662
this.buildMeta = undefined;
63+
/** @type {object} */
4764
this.buildInfo = undefined;
4865

4966
// Graph (per Compilation)
67+
/** @type {ModuleReason[]} */
5068
this.reasons = [];
69+
/** @type {SortableSet} */
5170
this._chunks = new SortableSet(undefined, sortById);
5271

5372
// Info from Compilation (per Compilation)
73+
/** @type {number | string} */
5474
this.id = null;
75+
/** @type {number} */
5576
this.index = null;
77+
/** @type {number} */
5678
this.index2 = null;
79+
/** @type {number} */
5780
this.depth = null;
81+
/** @type {Module} */
5882
this.issuer = null;
83+
/** @type {undefined | object} */
5984
this.profile = undefined;
85+
/** @type {boolean} */
6086
this.prefetched = false;
87+
/** @type {boolean} */
6188
this.built = false;
6289

6390
// Info from Optimization (per Compilation)
91+
/** @type {null | boolean} */
6492
this.used = null;
93+
/** @type {false | true | string[]} */
6594
this.usedExports = null;
95+
/** @type {(string | OptimizationBailoutFunction)[]} */
6696
this.optimizationBailout = [];
6797

6898
// delayed operations
99+
/** @type {undefined | {oldChunk: Chunk, newChunks: Chunk[]}[] } */
69100
this._rewriteChunkInReasons = undefined;
70101

102+
/** @type {boolean} */
71103
this.useSourceMap = false;
72104
}
73105

0 commit comments

Comments
 (0)