@@ -94,6 +94,7 @@ const { isSourceEqual } = require("./util/source");
94
94
/** @typedef {import("./AsyncDependenciesBlock") } AsyncDependenciesBlock */
95
95
/** @typedef {import("./Cache") } Cache */
96
96
/** @typedef {import("./CacheFacade") } CacheFacade */
97
+ /** @typedef {import("./Chunk").ChunkId } ChunkId */
97
98
/** @typedef {import("./ChunkGroup").ChunkGroupOptions } ChunkGroupOptions */
98
99
/** @typedef {import("./Compiler") } Compiler */
99
100
/** @typedef {import("./Compiler").CompilationParams } CompilationParams */
@@ -134,7 +135,7 @@ const { isSourceEqual } = require("./util/source");
134
135
/**
135
136
* @callback ModuleCallback
136
137
* @param {(WebpackError | null)= } err
137
- * @param {Module= } result
138
+ * @param {( Module | null) = } result
138
139
* @returns {void }
139
140
*/
140
141
@@ -247,7 +248,7 @@ const { isSourceEqual } = require("./util/source");
247
248
/**
248
249
* @typedef {object } LogEntry
249
250
* @property {string } type
250
- * @property {any[] } args
251
+ * @property {any[]= } args
251
252
* @property {number } time
252
253
* @property {string[]= } trace
253
254
*/
@@ -1055,6 +1056,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1055
1056
this . dependencyTemplates = new DependencyTemplates (
1056
1057
this . outputOptions . hashFunction
1057
1058
) ;
1059
+ /** @type {Record<string, number> } */
1058
1060
this . childrenCounters = { } ;
1059
1061
/** @type {Set<number|string> } */
1060
1062
this . usedChunkIds = null ;
@@ -1222,7 +1224,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1222
1224
logEntry . type === LogType . profileEnd &&
1223
1225
typeof console . profileEnd === "function"
1224
1226
) {
1225
- console . profileEnd ( `[${ name } ] ${ logEntry . args [ 0 ] } ` ) ;
1227
+ console . profileEnd (
1228
+ `[${ name } ] ${ /** @type {NonNullable<LogEntry["args"]> } */ ( logEntry . args ) [ 0 ] } `
1229
+ ) ;
1226
1230
}
1227
1231
if ( logEntries === undefined ) {
1228
1232
logEntries = this . logging . get ( name ) ;
@@ -1236,7 +1240,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1236
1240
logEntry . type === LogType . profile &&
1237
1241
typeof console . profile === "function"
1238
1242
) {
1239
- console . profile ( `[${ name } ] ${ logEntry . args [ 0 ] } ` ) ;
1243
+ console . profile (
1244
+ `[${ name } ] ${ /** @type {NonNullable<LogEntry["args"]> } */ ( logEntry . args ) [ 0 ] } `
1245
+ ) ;
1240
1246
}
1241
1247
}
1242
1248
} ,
@@ -2979,11 +2985,15 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2979
2985
2980
2986
this . assignDepths ( entryModules ) ;
2981
2987
2988
+ /**
2989
+ * @param {Dependency[] } deps deps
2990
+ * @returns {Module[] } sorted deps
2991
+ */
2982
2992
const mapAndSort = deps =>
2983
- deps
2984
- . map ( dep => this . moduleGraph . getModule ( dep ) )
2985
- . filter ( Boolean )
2986
- . sort ( compareModulesByIdentifier ) ;
2993
+ /** @type { Module[] } */
2994
+ ( deps . map ( dep => this . moduleGraph . getModule ( dep ) ) . filter ( Boolean ) ) . sort (
2995
+ compareModulesByIdentifier
2996
+ ) ;
2987
2997
const includedModules = [
2988
2998
...mapAndSort ( this . globalEntry . includeDependencies ) ,
2989
2999
...mapAndSort ( includeDependencies )
@@ -3355,7 +3365,8 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3355
3365
let delayedModules = new Set ( ) ;
3356
3366
asyncLib . eachLimit (
3357
3367
jobs ,
3358
- this . options . parallelism ,
3368
+ /** @type {number } */
3369
+ ( this . options . parallelism ) ,
3359
3370
( job , callback ) => {
3360
3371
const { module } = job ;
3361
3372
const { codeGenerationDependencies } = module ;
@@ -3734,13 +3745,24 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3734
3745
if ( chunkGroup !== undefined ) {
3735
3746
chunkGroup . addOptions ( groupOptions ) ;
3736
3747
if ( module ) {
3737
- chunkGroup . addOrigin ( module , loc , request ) ;
3748
+ chunkGroup . addOrigin (
3749
+ module ,
3750
+ /** @type {DependencyLocation } */
3751
+ ( loc ) ,
3752
+ request
3753
+ ) ;
3738
3754
}
3739
3755
return chunkGroup ;
3740
3756
}
3741
3757
}
3742
3758
const chunkGroup = new ChunkGroup ( groupOptions ) ;
3743
- if ( module ) chunkGroup . addOrigin ( module , loc , request ) ;
3759
+ if ( module )
3760
+ chunkGroup . addOrigin (
3761
+ module ,
3762
+ /** @type {DependencyLocation } */
3763
+ ( loc ) ,
3764
+ request
3765
+ ) ;
3744
3766
const chunk = this . addChunk ( name ) ;
3745
3767
3746
3768
connectChunkGroupAndChunk ( chunkGroup , chunk ) ;
@@ -4400,9 +4422,9 @@ This prevents using hashes of each other and should be avoided.`);
4400
4422
const chunkHash = createHash ( hashFunction ) ;
4401
4423
chunkHash . update ( chunk . hash ) ;
4402
4424
chunkHash . update ( this . hash ) ;
4403
- const chunkHashDigest = /** @type { string } */ (
4404
- chunkHash . digest ( hashDigest )
4405
- ) ;
4425
+ const chunkHashDigest =
4426
+ /** @type { string } */
4427
+ ( chunkHash . digest ( hashDigest ) ) ;
4406
4428
chunk . hash = chunkHashDigest ;
4407
4429
chunk . renderedHash = chunk . hash . slice ( 0 , hashDigestLength ) ;
4408
4430
this . hooks . contentHash . call ( chunk ) ;
@@ -4861,7 +4883,7 @@ This prevents using hashes of each other and should be avoided.`);
4861
4883
}
4862
4884
} catch ( err ) {
4863
4885
if ( ! inTry ) throw err ;
4864
- errorAndCallback ( err ) ;
4886
+ errorAndCallback ( /** @type { Error } */ ( err ) ) ;
4865
4887
}
4866
4888
} ) ;
4867
4889
} ,
@@ -5001,7 +5023,7 @@ This prevents using hashes of each other and should be avoided.`);
5001
5023
const runtimeTemplate = this . runtimeTemplate ;
5002
5024
5003
5025
const chunk = new Chunk ( "build time chunk" , this . _backCompat ) ;
5004
- chunk . id = chunk . name ;
5026
+ chunk . id = /** @type { ChunkId } */ ( chunk . name ) ;
5005
5027
chunk . ids = [ chunk . id ] ;
5006
5028
chunk . runtime = runtime ;
5007
5029
0 commit comments