🗝️ chore: Use Element Access over any-Casts in Registry Cache Spec (#13664)

The as-any casts existed only to reach the protected Keyv cache and
private localSnapshotExpiry members. TypeScript's element-access escape
hatch provides the same access fully typed, so the casts and their
eslint-disable directives are unnecessary. The directives also reported
as unused under configs that relax no-explicit-any for test files.
This commit is contained in:
Danny Avila
2026-06-10 20:40:33 -04:00
committed by GitHub
parent a52c82489e
commit 7a8a18f07d

View File

@@ -254,8 +254,7 @@ describe('ServerConfigsCacheRedisAggregateKey Integration Tests', () => {
await cache.getAll();
// Spy on the underlying Keyv cache to count Redis calls
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const cacheGetSpy = jest.spyOn((cache as any).cache, 'get');
const cacheGetSpy = jest.spyOn(cache['cache'], 'get');
await cache.getAll();
await cache.getAll();
@@ -325,11 +324,9 @@ describe('ServerConfigsCacheRedisAggregateKey Integration Tests', () => {
await cache.getAll(); // prime snapshot
// Force-expire the snapshot without sleeping
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(cache as any).localSnapshotExpiry = Date.now() - 1;
cache['localSnapshotExpiry'] = Date.now() - 1;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const cacheGetSpy = jest.spyOn((cache as any).cache, 'get');
const cacheGetSpy = jest.spyOn(cache['cache'], 'get');
const result = await cache.getAll();
expect(cacheGetSpy.mock.calls).toHaveLength(1);
expect(Object.keys(result).length).toBe(1);