Skip to content

Fix TypeScript Type Inconsistency in TTLCache.compress Method - #8341

Closed
tmdeveloper007 wants to merge 1 commit into
JhaSourav07:mainfrom
tmdeveloper007:#8331
Closed

Fix TypeScript Type Inconsistency in TTLCache.compress Method#8341
tmdeveloper007 wants to merge 1 commit into
JhaSourav07:mainfrom
tmdeveloper007:#8331

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Summary of What Has Been Done

Fixed the TypeScript type inconsistency in TTLCache.compress method in lib/cache.ts. The CacheItem<T> type was updated to explicitly document that the value field can hold either a plain T or a brotli-compressed Buffer. The internal store type was updated to use the correct generic parameter.

Changes Made

  • lib/cache.ts: Updated CacheItem<T> type comment to explicitly document value: T | Buffer. Changed internal store from Map<string, CacheItem<T | Buffer>> to Map<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 decompress method now correctly narrows T | Buffer back to T without type casts.

Closes #8331

Note: Please assign this PR to the tmdeveloper007 account.

@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

@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.

@retenta-bot

retenta-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown

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!

@retenta-bot retenta-bot Bot changed the title fix(cache): added explicit type documentation for TTLCache compress return Fix TypeScript Type Inconsistency in TTLCache.compress Method Jul 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 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:

  1. Claim the issue — Comment /claim on #8331 if you are the issue author, or ask a maintainer to /assign you.
  2. Wait for confirmation — The bot will confirm your assignment with a ✅ reply.
  3. Then open your PR — Link the issue with Fixes #8331 in your description.

💡 You can be assigned to up to 5 open issues at a time. Check your current assignments before claiming a new one.

We look forward to your contribution once you're assigned! 🚀

@github-actions github-actions Bot closed this Jul 26, 2026
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.

fix(cache): correct compress return type in TTLCache

1 participant