@@ -44,10 +44,8 @@ const stringifyIdSortPredicate = (a, b) => {
4444 return 0 ;
4545} ;
4646
47- //TODO: Change type to Module when import works
48- //https://github.com/Microsoft/TypeScript/issues/23375
4947/**
50- * @param {HasId } module the module to compare against
48+ * @param {Module } module the module to compare against
5149 * @returns {boolean } return true if module.id is equal to type "number"
5250 */
5351const moduleIdIsNumber = module => {
@@ -177,17 +175,19 @@ class Template {
177175
178176 /**
179177 *
180- * @param {HasId [] } modules - a collection of modules to get array bounds for
178+ * @param {Module [] } modules a collection of modules to get array bounds for
181179 * @returns {[number, number] | false } returns the upper and lower array bounds
182180 * or false if not every module has a number based id
183181 */
184182 static getModulesArrayBounds ( modules ) {
183+ // Typeguards don't work for .every() with predicate functions
184+ // https://github.com/Microsoft/TypeScript/issues/23799
185185 if ( ! modules . every ( moduleIdIsNumber ) ) return false ;
186186 var maxId = - Infinity ;
187187 var minId = Infinity ;
188188 for ( const module of modules ) {
189- if ( maxId < module . id ) maxId = module . id ;
190- if ( minId > module . id ) minId = module . id ;
189+ if ( maxId < module . id ) maxId = /** @type { number } */ ( module . id ) ;
190+ if ( minId > module . id ) minId = /** @type { number } */ ( module . id ) ;
191191 }
192192 if ( minId < 16 + ( "" + minId ) . length ) {
193193 // add minId x ',' instead of 'Array(minId).concat(…)'
@@ -206,7 +206,6 @@ class Template {
206206 }
207207
208208 /**
209- *
210209 * @param {Chunk } chunk chunk whose modules will be rendered
211210 * @param {ModuleFilterPredicate } filterFn function used to filter modules from chunk to render
212211 * @param {ModuleTemplate } moduleTemplate ModuleTemplate instance used to render modules
0 commit comments