@@ -44,10 +44,8 @@ const stringifyIdSortPredicate = (a, b) => {
44
44
return 0 ;
45
45
} ;
46
46
47
- //TODO: Change type to Module when import works
48
- //https://github.com/Microsoft/TypeScript/issues/23375
49
47
/**
50
- * @param {HasId } module the module to compare against
48
+ * @param {Module } module the module to compare against
51
49
* @returns {boolean } return true if module.id is equal to type "number"
52
50
*/
53
51
const moduleIdIsNumber = module => {
@@ -177,17 +175,19 @@ class Template {
177
175
178
176
/**
179
177
*
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
181
179
* @returns {[number, number] | false } returns the upper and lower array bounds
182
180
* or false if not every module has a number based id
183
181
*/
184
182
static getModulesArrayBounds ( modules ) {
183
+ // Typeguards don't work for .every() with predicate functions
184
+ // https://github.com/Microsoft/TypeScript/issues/23799
185
185
if ( ! modules . every ( moduleIdIsNumber ) ) return false ;
186
186
var maxId = - Infinity ;
187
187
var minId = Infinity ;
188
188
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 ) ;
191
191
}
192
192
if ( minId < 16 + ( "" + minId ) . length ) {
193
193
// add minId x ',' instead of 'Array(minId).concat(…)'
@@ -206,7 +206,6 @@ class Template {
206
206
}
207
207
208
208
/**
209
- *
210
209
* @param {Chunk } chunk chunk whose modules will be rendered
211
210
* @param {ModuleFilterPredicate } filterFn function used to filter modules from chunk to render
212
211
* @param {ModuleTemplate } moduleTemplate ModuleTemplate instance used to render modules
0 commit comments