Files Affected: All test files
Current Pattern:
const scanDir = (processor as any).scanDirectory.bind(processor);Proposed Solution:
// Create test-utils/types.ts
export function getPrivateMethod<T, K extends keyof T>(
instance: T,
methodName: K
): T[K] {
return instance[methodName];
}Files: __tests__/*.test.ts
Current:
mockFs.readdir.mockImplementation(async (dir: any) => { ... });Proposed: Create proper mock types for fs operations
File: src/cli.ts:391
Current:
method: (options.method as any) || "subimage"Proposed:
type AlignmentMethod = "feature" | "phase" | "subimage" | "opencv";
method: (options.method as AlignmentMethod) || "subimage"File: src/types/opencv-js.d.ts
Status: Currently using any as a placeholder
Action: Either:
- Find community @types/opencv.js package
- Expand current type definitions based on actual usage
- Keep minimal types since OpenCV is currently disabled
Many as any usages in tests are for creating partial mock objects.
Consider using:
jest.mocked()helper- Partial types
- Deep partial utility types
- Current 'any' count: 70
- Current type assertions: 187
- Goal: Reduce by 50% without compromising test flexibility