@@ -43,7 +43,7 @@ const {
4343/** @typedef {import("./ModuleGraph") } ModuleGraph */
4444/** @typedef {import("./ModuleGraphConnection").ConnectionState } ConnectionState */
4545/** @typedef {import("./RuntimeModule") } RuntimeModule */
46- /** @typedef {typeof import("./util/Hash")} Hash */
46+ /** @typedef {import("./util/Hash").HashFunction } HashFunction */
4747/** @typedef {import("./util/runtime").RuntimeSpec } RuntimeSpec */
4848
4949/** @type {ReadonlySet<string> } */
@@ -69,7 +69,9 @@ class ModuleHashInfo {
6969 * @param {string } renderedHash rendered hash
7070 */
7171 constructor ( hash , renderedHash ) {
72+ /** @type {string } */
7273 this . hash = hash ;
74+ /** @type {string } */
7375 this . renderedHash = renderedHash ;
7476 }
7577}
@@ -95,10 +97,11 @@ const getModuleRuntimes = (chunks) => {
9597
9698/**
9799 * @param {SourceTypesByModule | undefined } sourceTypesByModule sourceTypesByModule
98- * @returns {(set: SortableSet<Module>) => Map<string, SortableSet<Module>> } modules by source type
100+ * @returns {ModulesBySourceType } modules by source type
99101 */
100102const modulesBySourceType = ( sourceTypesByModule ) => ( set ) => {
101- /** @type {Map<SourceType, SortableSet<Module>> } */
103+ /** @typedef {SortableSet<Module> } ModuleSortableSet */
104+ /** @type {Map<SourceType, ModuleSortableSet> } */
102105 const map = new Map ( ) ;
103106 for ( const module of set ) {
104107 const sourceTypes =
@@ -107,6 +110,7 @@ const modulesBySourceType = (sourceTypesByModule) => (set) => {
107110 for ( const sourceType of sourceTypes ) {
108111 let innerSet = map . get ( sourceType ) ;
109112 if ( innerSet === undefined ) {
113+ /** @type {ModuleSortableSet } */
110114 innerSet = new SortableSet ( ) ;
111115 map . set ( sourceType , innerSet ) ;
112116 }
@@ -122,6 +126,10 @@ const modulesBySourceType = (sourceTypesByModule) => (set) => {
122126 }
123127 return map ;
124128} ;
129+
130+ /** @typedef {(set: SortableSet<Module>) => Map<string, SortableSet<Module>> } ModulesBySourceType */
131+
132+ /** @type {ModulesBySourceType } */
125133const defaultModulesBySourceType = modulesBySourceType ( undefined ) ;
126134
127135/**
@@ -164,11 +172,14 @@ const getModulesSize = (modules) => {
164172 return size ;
165173} ;
166174
175+ /** @typedef {Record<string, number> } SizesOfModules */
176+
167177/**
168178 * @param {Iterable<Module> } modules the sortable Set to get the size of
169- * @returns {Record<string, number> } the sizes of the modules
179+ * @returns {SizesOfModules } the sizes of the modules
170180 */
171181const getModulesSizes = ( modules ) => {
182+ /** @type {SizesOfModules } */
172183 const sizes = Object . create ( null ) ;
173184 for ( const module of modules ) {
174185 for ( const type of module . getSourceTypes ( ) ) {
@@ -199,6 +210,7 @@ const isAvailableChunk = (a, b) => {
199210/** @typedef {Set<Chunk> } EntryInChunks */
200211/** @typedef {Set<Chunk> } RuntimeInChunks */
201212/** @typedef {string | number } ModuleId */
213+ /** @typedef {RuntimeSpecMap<Set<string>, RuntimeRequirements> } ChunkGraphRuntimeRequirements */
202214
203215class ChunkGraphModule {
204216 constructor ( ) {
@@ -212,7 +224,7 @@ class ChunkGraphModule {
212224 this . hashes = undefined ;
213225 /** @type {ModuleId | null } */
214226 this . id = null ;
215- /** @type {RuntimeSpecMap<Set<string>, RuntimeRequirements> | undefined } */
227+ /** @type {ChunkGraphRuntimeRequirements | undefined } */
216228 this . runtimeRequirements = undefined ;
217229 /** @type {RuntimeSpecMap<string, bigint> | undefined } */
218230 this . graphHashes = undefined ;
@@ -242,7 +254,7 @@ class ChunkGraphChunk {
242254 this . runtimeRequirements = undefined ;
243255 /** @type {Set<string> } */
244256 this . runtimeRequirementsInTree = new Set ( ) ;
245-
257+ /** @type { ModulesBySourceType } */
246258 this . _modulesBySourceType = defaultModulesBySourceType ;
247259 }
248260}
@@ -251,13 +263,14 @@ class ChunkGraphChunk {
251263/** @typedef {Record<ModuleId, string> } IdToHashMap */
252264/** @typedef {Record<ChunkId, IdToHashMap> } ChunkModuleHashMap */
253265/** @typedef {Record<ChunkId, ModuleId[]> } ChunkModuleIdMap */
266+ /** @typedef {Record<ChunkId, boolean> } ChunkConditionMap */
254267
255268/** @typedef {(a: Module, b: Module) => -1 | 0 | 1 } ModuleComparator */
256269
257270class ChunkGraph {
258271 /**
259272 * @param {ModuleGraph } moduleGraph the module graph
260- * @param {string | Hash } hashFunction the hash function to use
273+ * @param {HashFunction } hashFunction the hash function to use
261274 */
262275 constructor ( moduleGraph , hashFunction = DEFAULTS . HASH_FUNCTION ) {
263276 /**
@@ -809,6 +822,7 @@ class ChunkGraph {
809822 ) ) {
810823 if ( filterFn ( module ) ) {
811824 if ( idToHashMap === undefined ) {
825+ /** @type {IdToHashMap } */
812826 idToHashMap = Object . create ( null ) ;
813827 chunkModuleHashMap [ /** @type {ChunkId } */ ( asyncChunk . id ) ] =
814828 /** @type {IdToHashMap } */
@@ -830,9 +844,10 @@ class ChunkGraph {
830844 /**
831845 * @param {Chunk } chunk the chunk
832846 * @param {ChunkFilterPredicate } filterFn function used to filter chunks
833- * @returns {Record<ChunkId, boolean> } chunk map
847+ * @returns {ChunkConditionMap } chunk condition map
834848 */
835849 getChunkConditionMap ( chunk , filterFn ) {
850+ /** @type {ChunkConditionMap } */
836851 const map = Object . create ( null ) ;
837852 for ( const c of chunk . getAllReferencedChunks ( ) ) {
838853 map [ /** @type {ChunkId } */ ( c . id ) ] = filterFn ( c , this ) ;
@@ -848,6 +863,7 @@ class ChunkGraph {
848863 */
849864 hasModuleInGraph ( chunk , filterFn , filterChunkFn ) {
850865 const queue = new Set ( chunk . groupsIterable ) ;
866+ /** @type {Set<Chunk> } */
851867 const chunksProcessed = new Set ( ) ;
852868
853869 for ( const chunkGroup of queue ) {
@@ -1556,6 +1572,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
15561572 const cgm = this . _getChunkGraphModule ( module ) ;
15571573 const runtimeRequirementsMap = cgm . runtimeRequirements ;
15581574 if ( runtimeRequirementsMap === undefined ) {
1575+ /** @type {ChunkGraphRuntimeRequirements } */
15591576 const map = new RuntimeSpecMap ( ) ;
15601577 // TODO avoid cloning item and track ownership instead
15611578 map . set ( runtime , transferOwnership ? items : new Set ( items ) ) ;
0 commit comments