Fix TypeScript Type Inconsistency in TTLCache.compress Method - #8341
Fix TypeScript Type Inconsistency in TTLCache.compress Method#8341tmdeveloper007 wants to merge 1 commit into
Conversation
|
@tmdeveloper007 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
This pull request improves the TypeScript type safety of the TTLCache.compress method by clarifying the value type in CacheItem. This change enhances the developer experience by making the cache compression behavior explicit. It's worth noting that this aligns with previous decisions made to ensure consistency in cache key validation and memory management in the TTLCache. Thank you for your contribution, and feel free to reach out if you have any questions! |
|
👋 Hey @tmdeveloper007! Thanks for your interest in contributing to CommitPulse! 🙏 Unfortunately, this PR has been automatically closed because you are not assigned to the linked issue #8331 — fix(cache): correct compress return type in TTLCache. To avoid this in the future, please follow these steps:
We look forward to your contribution once you're assigned! 🚀 |
Summary of What Has Been Done
Fixed the TypeScript type inconsistency in
TTLCache.compressmethod inlib/cache.ts. TheCacheItem<T>type was updated to explicitly document that thevaluefield can hold either a plainTor a brotli-compressedBuffer. The internalstoretype was updated to use the correct generic parameter.Changes Made
CacheItem<T>type comment to explicitly documentvalue: T | Buffer. Changed internal store fromMap<string, CacheItem<T | Buffer>>toMap<string, CacheItem<T>>with the correct value type. Added JSDoc clarifying the compression behavior.Impact it Made
Fixes TypeScript type inconsistencies and improves developer experience by making the cache compression behavior explicit and type-safe. The
decompressmethod now correctly narrowsT | Bufferback toTwithout type casts.Closes #8331
Note: Please assign this PR to the
tmdeveloper007account.