Skip to content

Add TypeScript types throughout codebase#3

Merged
simllll merged 3 commits into
mainfrom
claude/add-typescript-types-DHKSQ
Jan 21, 2026
Merged

Add TypeScript types throughout codebase#3
simllll merged 3 commits into
mainfrom
claude/add-typescript-types-DHKSQ

Conversation

@simllll

@simllll simllll commented Jan 21, 2026

Copy link
Copy Markdown
Owner
  • Add ICacheOptions interface for cache configuration options
  • Add ICacheMeta interface for cache entry metadata
  • Update ICacheEntry interface to use generic types
  • Replace any[] with unknown[] for function arguments in key strategies
  • Replace any with unknown for cache content parameters across all storage implementations
  • Add IMultiCacheKeyStrategy interface for multi-cache decorator
  • Add proper type guards in ExpirationStrategy
  • Update all storage implementations (Memory, FS JSON, LRU, LRU-Redis, NodeCache, Redis, RedisIO) with proper types
  • Fix test files to use unknown instead of any for error handling and arguments

This improves type safety across the entire codebase by eliminating all any types, making the library more robust and easier to maintain.

- Add ICacheOptions interface for cache configuration options
- Add ICacheMeta interface for cache entry metadata
- Update ICacheEntry interface to use generic types
- Replace `any[]` with `unknown[]` for function arguments in key strategies
- Replace `any` with `unknown` for cache content parameters across all storage implementations
- Add IMultiCacheKeyStrategy interface for multi-cache decorator
- Add proper type guards in ExpirationStrategy
- Update all storage implementations (Memory, FS JSON, LRU, LRU-Redis, NodeCache, Redis, RedisIO) with proper types
- Fix test files to use `unknown` instead of `any` for error handling and arguments

This improves type safety across the entire codebase by eliminating all `any` types,
making the library more robust and easier to maintain.
- Add generic type parameter `<T>` to setItem methods in all interfaces
  allowing type-safe content storage: `setItem<T>(key, content: T | undefined)`
- Update AbstractBaseStrategy and ExpirationStrategy with generic setItem
- Update all storage implementations with generic setItem methods
- Narrow intermediate deserialization types in Redis storages from `unknown`
  to more specific union types (e.g., `string | T` during JSON parsing)
- Fix test to use explicit union type for mixed content arrays

This improves type inference and allows consumers to get compile-time
type checking when storing typed data in the cache.
@simllll simllll merged commit de2bab4 into main Jan 21, 2026
5 checks passed
@simllll simllll deleted the claude/add-typescript-types-DHKSQ branch January 22, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants