diff --git a/ext/js/general/cache-map.js b/ext/js/general/cache-map.js index 8650d8e694..a995b8c7b6 100644 --- a/ext/js/general/cache-map.js +++ b/ext/js/general/cache-map.js @@ -29,6 +29,7 @@ export class CacheMap { */ constructor(maxSize) { if (!( + typeof maxSize === 'number' && Number.isFinite(maxSize) && maxSize >= 0 && Math.floor(maxSize) === maxSize diff --git a/test/cache-map.test.js b/test/cache-map.test.js index 9db306772b..52ada57ca8 100644 --- a/test/cache-map.test.js +++ b/test/cache-map.test.js @@ -31,7 +31,9 @@ function testConstructor() { [true, () => new CacheMap(-1)], [true, () => new CacheMap(1.5)], [true, () => new CacheMap(Number.NaN)], - [true, () => new CacheMap(Number.POSITIVE_INFINITY)] + [true, () => new CacheMap(Number.POSITIVE_INFINITY)], + // @ts-expect-error - Ignore because it should throw an error + [true, () => new CacheMap('a')] ]; for (const [throws, create] of data) {