Skip to content

Commit 02590bf

Browse files
chore: improve types
1 parent fe65ecd commit 02590bf

24 files changed

+186
-8
lines changed

lib/AsyncDependenciesBlock.js

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const makeSerializable = require("./util/makeSerializable");
1515
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
1616
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
1717
/** @typedef {import("./Module")} Module */
18+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
19+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
1820
/** @typedef {import("./util/Hash")} Hash */
1921

2022
class AsyncDependenciesBlock extends DependenciesBlock {
@@ -71,6 +73,9 @@ class AsyncDependenciesBlock extends DependenciesBlock {
7173
super.updateHash(hash, context);
7274
}
7375

76+
/**
77+
* @param {ObjectSerializerContext} context context
78+
*/
7479
serialize(context) {
7580
const { write } = context;
7681
write(this.groupOptions);
@@ -79,6 +84,9 @@ class AsyncDependenciesBlock extends DependenciesBlock {
7984
super.serialize(context);
8085
}
8186

87+
/**
88+
* @param {ObjectDeserializerContext} context context
89+
*/
8290
deserialize(context) {
8391
const { read } = context;
8492
this.groupOptions = read();

lib/ContextModule.js

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ const makeSerializable = require("./util/makeSerializable");
4343
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
4444
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
4545
/** @typedef {import("./dependencies/ContextElementDependency")} ContextElementDependency */
46+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
47+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
4648
/** @template T @typedef {import("./util/LazySet")<T>} LazySet<T> */
4749
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
4850

@@ -1151,13 +1153,19 @@ module.exports = webpackEmptyAsyncContext;`;
11511153
return size;
11521154
}
11531155

1156+
/**
1157+
* @param {ObjectSerializerContext} context context
1158+
*/
11541159
serialize(context) {
11551160
const { write } = context;
11561161
write(this._identifier);
11571162
write(this._forceBuild);
11581163
super.serialize(context);
11591164
}
11601165

1166+
/**
1167+
* @param {ObjectDeserializerContext} context context
1168+
*/
11611169
deserialize(context) {
11621170
const { read } = context;
11631171
this._identifier = read();

lib/DelegatedModule.js

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const makeSerializable = require("./util/makeSerializable");
3030
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
3131
/** @typedef {import("./WebpackError")} WebpackError */
3232
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
33+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
34+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
3335
/** @typedef {import("./util/Hash")} Hash */
3436
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
3537

@@ -186,6 +188,9 @@ class DelegatedModule extends Module {
186188
super.updateHash(hash, context);
187189
}
188190

191+
/**
192+
* @param {ObjectSerializerContext} context context
193+
*/
189194
serialize(context) {
190195
const { write } = context;
191196
// constructor

lib/DependenciesBlock.js

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const makeSerializable = require("./util/makeSerializable");
1212
/** @typedef {import("./ChunkGroup")} ChunkGroup */
1313
/** @typedef {import("./Dependency")} Dependency */
1414
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
15+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
16+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
1517
/** @typedef {import("./util/Hash")} Hash */
1618

1719
/** @typedef {(d: Dependency) => boolean} DependencyFilterFunction */
@@ -88,11 +90,17 @@ class DependenciesBlock {
8890
}
8991
}
9092

93+
/**
94+
* @param {ObjectSerializerContext} context context
95+
*/
9196
serialize({ write }) {
9297
write(this.dependencies);
9398
write(this.blocks);
9499
}
95100

101+
/**
102+
* @param {ObjectDeserializerContext} context context
103+
*/
96104
deserialize({ read }) {
97105
this.dependencies = read();
98106
this.blocks = read();

lib/DllModule.js

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const makeSerializable = require("./util/makeSerializable");
2525
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
2626
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
2727
/** @typedef {import("./WebpackError")} WebpackError */
28+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
29+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
2830
/** @typedef {import("./util/Hash")} Hash */
2931
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
3032

@@ -122,11 +124,17 @@ class DllModule extends Module {
122124
super.updateHash(hash, context);
123125
}
124126

127+
/**
128+
* @param {ObjectSerializerContext} context context
129+
*/
125130
serialize(context) {
126131
context.write(this.name);
127132
super.serialize(context);
128133
}
129134

135+
/**
136+
* @param {ObjectDeserializerContext} context context
137+
*/
130138
deserialize(context) {
131139
this.name = context.read();
132140
super.deserialize(context);

lib/ExternalModule.js

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const { register } = require("./util/serialization");
3939
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
4040
/** @typedef {import("./WebpackError")} WebpackError */
4141
/** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
42+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
43+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
4244
/** @typedef {import("./util/Hash")} Hash */
4345
/** @typedef {typeof import("./util/Hash")} HashConstructor */
4446
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
@@ -733,6 +735,9 @@ class ExternalModule extends Module {
733735
super.updateHash(hash, context);
734736
}
735737

738+
/**
739+
* @param {ObjectSerializerContext} context context
740+
*/
736741
serialize(context) {
737742
const { write } = context;
738743

@@ -743,6 +748,9 @@ class ExternalModule extends Module {
743748
super.serialize(context);
744749
}
745750

751+
/**
752+
* @param {ObjectDeserializerContext} context context
753+
*/
746754
deserialize(context) {
747755
const { read } = context;
748756

lib/FileSystemInfo.js

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const processAsyncTree = require("./util/processAsyncTree");
1818

1919
/** @typedef {import("./WebpackError")} WebpackError */
2020
/** @typedef {import("./logging/Logger").Logger} Logger */
21+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
22+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
2123
/** @typedef {typeof import("./util/Hash")} Hash */
2224
/** @typedef {import("./util/fs").IStats} IStats */
2325
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
@@ -378,6 +380,9 @@ class Snapshot {
378380
this.children.add(child);
379381
}
380382

383+
/**
384+
* @param {ObjectSerializerContext} context context
385+
*/
381386
serialize({ write }) {
382387
write(this._flags);
383388
if (this.hasStartTime()) write(this.startTime);
@@ -395,6 +400,9 @@ class Snapshot {
395400
if (this.hasChildren()) write(this.children);
396401
}
397402

403+
/**
404+
* @param {ObjectDeserializerContext} context context
405+
*/
398406
deserialize({ read }) {
399407
this._flags = read();
400408
if (this.hasStartTime()) this.startTime = read();

lib/Module.js

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const makeSerializable = require("./util/makeSerializable");
3333
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
3434
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
3535
/** @typedef {import("./WebpackError")} WebpackError */
36+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
37+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
3638
/** @typedef {import("./util/Hash")} Hash */
3739
/** @template T @typedef {import("./util/LazySet")<T>} LazySet<T> */
3840
/** @template T @typedef {import("./util/SortableSet")<T>} SortableSet<T> */
@@ -976,6 +978,9 @@ class Module extends DependenciesBlock {
976978
buildDependencies
977979
) {}
978980

981+
/**
982+
* @param {ObjectSerializerContext} context context
983+
*/
979984
serialize(context) {
980985
const { write } = context;
981986
write(this.type);
@@ -1002,6 +1007,9 @@ class Module extends DependenciesBlock {
10021007
super.serialize(context);
10031008
}
10041009

1010+
/**
1011+
* @param {ObjectDeserializerContext} context context
1012+
*/
10051013
deserialize(context) {
10061014
const { read } = context;
10071015
this.type = read();

lib/ModuleBuildError.js

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const { cutOffLoaderExecution } = require("./ErrorHelpers");
99
const WebpackError = require("./WebpackError");
1010
const makeSerializable = require("./util/makeSerializable");
1111

12+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
13+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
14+
1215
class ModuleBuildError extends WebpackError {
1316
/**
1417
* @param {string | Error&any} err error thrown
@@ -55,6 +58,9 @@ class ModuleBuildError extends WebpackError {
5558
this.error = err;
5659
}
5760

61+
/**
62+
* @param {ObjectSerializerContext} context context
63+
*/
5864
serialize(context) {
5965
const { write } = context;
6066

@@ -63,6 +69,9 @@ class ModuleBuildError extends WebpackError {
6369
super.serialize(context);
6470
}
6571

72+
/**
73+
* @param {ObjectDeserializerContext} context context
74+
*/
6675
deserialize(context) {
6776
const { read } = context;
6877

lib/ModuleError.js

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const { cleanUp } = require("./ErrorHelpers");
99
const WebpackError = require("./WebpackError");
1010
const makeSerializable = require("./util/makeSerializable");
1111

12+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
13+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
14+
1215
class ModuleError extends WebpackError {
1316
/**
1417
* @param {Error} err error thrown
@@ -39,6 +42,9 @@ class ModuleError extends WebpackError {
3942
: undefined;
4043
}
4144

45+
/**
46+
* @param {ObjectSerializerContext} context context
47+
*/
4248
serialize(context) {
4349
const { write } = context;
4450

@@ -47,6 +53,9 @@ class ModuleError extends WebpackError {
4753
super.serialize(context);
4854
}
4955

56+
/**
57+
* @param {ObjectDeserializerContext} context context
58+
*/
5059
deserialize(context) {
5160
const { read } = context;
5261

lib/ModuleParseError.js

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
const WebpackError = require("./WebpackError");
99
const makeSerializable = require("./util/makeSerializable");
1010

11+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
12+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
13+
1114
const WASM_HEADER = Buffer.from([0x00, 0x61, 0x73, 0x6d]);
1215

1316
class ModuleParseError extends WebpackError {
@@ -87,6 +90,9 @@ class ModuleParseError extends WebpackError {
8790
this.error = err;
8891
}
8992

93+
/**
94+
* @param {ObjectSerializerContext} context context
95+
*/
9096
serialize(context) {
9197
const { write } = context;
9298

@@ -95,6 +101,9 @@ class ModuleParseError extends WebpackError {
95101
super.serialize(context);
96102
}
97103

104+
/**
105+
* @param {ObjectDeserializerContext} context context
106+
*/
98107
deserialize(context) {
99108
const { read } = context;
100109

lib/ModuleWarning.js

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const { cleanUp } = require("./ErrorHelpers");
99
const WebpackError = require("./WebpackError");
1010
const makeSerializable = require("./util/makeSerializable");
1111

12+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
13+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
14+
1215
class ModuleWarning extends WebpackError {
1316
/**
1417
* @param {Error} warning error thrown
@@ -39,6 +42,9 @@ class ModuleWarning extends WebpackError {
3942
: undefined;
4043
}
4144

45+
/**
46+
* @param {ObjectSerializerContext} context context
47+
*/
4248
serialize(context) {
4349
const { write } = context;
4450

@@ -47,6 +53,9 @@ class ModuleWarning extends WebpackError {
4753
super.serialize(context);
4854
}
4955

56+
/**
57+
* @param {ObjectDeserializerContext} context context
58+
*/
5059
deserialize(context) {
5160
const { read } = context;
5261

lib/NormalModule.js

+8
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ const memoize = require("./util/memoize");
7171
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
7272
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
7373
/** @typedef {import("./logging/Logger").Logger} WebpackLogger */
74+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
75+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
7476
/** @typedef {import("./util/Hash")} Hash */
7577
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
7678
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
@@ -1365,6 +1367,9 @@ class NormalModule extends Module {
13651367
super.updateHash(hash, context);
13661368
}
13671369

1370+
/**
1371+
* @param {ObjectSerializerContext} context context
1372+
*/
13681373
serialize(context) {
13691374
const { write } = context;
13701375
// deserialize
@@ -1399,6 +1404,9 @@ class NormalModule extends Module {
13991404
return obj;
14001405
}
14011406

1407+
/**
1408+
* @param {ObjectDeserializerContext} context context
1409+
*/
14021410
deserialize(context) {
14031411
const { read } = context;
14041412
this._source = read();

lib/RawModule.js

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const makeSerializable = require("./util/makeSerializable");
2323
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
2424
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
2525
/** @typedef {import("./WebpackError")} WebpackError */
26+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
27+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
2628
/** @typedef {import("./util/Hash")} Hash */
2729
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
2830

@@ -125,6 +127,9 @@ class RawModule extends Module {
125127
super.updateHash(hash, context);
126128
}
127129

130+
/**
131+
* @param {ObjectSerializerContext} context context
132+
*/
128133
serialize(context) {
129134
const { write } = context;
130135

@@ -136,6 +141,9 @@ class RawModule extends Module {
136141
super.serialize(context);
137142
}
138143

144+
/**
145+
* @param {ObjectDeserializerContext} context context
146+
*/
139147
deserialize(context) {
140148
const { read } = context;
141149

0 commit comments

Comments
 (0)