Skip to content

keyv - refactor: remove opts property from Keyv class#1843

Merged
jaredwray merged 4 commits intomainfrom
claude/remove-opts-property-iOI7I
Feb 15, 2026
Merged

keyv - refactor: remove opts property from Keyv class#1843
jaredwray merged 4 commits intomainfrom
claude/remove-opts-property-iOI7I

Conversation

@jaredwray
Copy link
Owner

Replace the public opts property with private backing fields and
public getters/setters. The constructor now uses a local mergedOptions
variable instead of storing configuration on this.opts. Added new
emitErrors getter/setter and _emitErrors private field. Updated
all internal method references to use private fields directly and
updated tests to use public getters instead of opts.

https://claude.ai/code/session_016DDrEfvCF1pcgvoX4hdkf7

Replace the public `opts` property with private backing fields and
public getters/setters. The constructor now uses a local mergedOptions
variable instead of storing configuration on `this.opts`. Added new
`emitErrors` getter/setter and `_emitErrors` private field. Updated
all internal method references to use private fields directly and
updated tests to use public getters instead of `opts`.

https://claude.ai/code/session_016DDrEfvCF1pcgvoX4hdkf7
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jaredwray, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the Keyv class to enhance encapsulation and maintainability by eliminating the direct public opts property. Configuration options are now managed through private backing fields and controlled public getters and setters. This change centralizes option handling within the class, making the internal state more robust and less prone to external manipulation, while also introducing explicit control over error emission.

Highlights

  • Encapsulation Refactor: Removed the public opts property from the Keyv class, replacing it with private backing fields and public getters/setters for improved encapsulation.
  • Constructor Logic Update: The constructor now utilizes a local mergedOptions variable for configuration, ensuring that options are processed and assigned to private fields rather than a public opts object.
  • New Error Emission Control: Introduced a new private field _emitErrors and corresponding public emitErrors getter/setter to explicitly control whether errors are emitted by the Keyv instance.
  • Internal Reference Updates: All internal method references within the Keyv class were updated to directly use the new private fields (e.g., _store, _compression, _namespace) instead of accessing properties via this.opts.
  • Test Suite Alignment: Existing tests were updated to reflect these changes, now using the public getters (e.g., keyv.namespace, keyv.ttl) instead of directly accessing keyv.opts.
Changelog
  • core/keyv/src/index.ts
    • Removed the KeyvOptions_ type definition.
    • Eliminated the opts property from the Keyv class.
    • Added a new private field _emitErrors initialized to true.
    • Modified the constructor to process options into a local mergedOptions variable, then assign values to private fields.
    • Updated all internal references from this.opts.propertyName to this._propertyName or mergedOptions.propertyName.
    • Removed assignments to this.opts.propertyName within public setters.
    • Implemented public emitErrors getter and setter to control error emission.
    • Adjusted the emit method to check this._emitErrors instead of this.opts.emitErrors.
    • Changed store property access in various methods (e.g., get, getMany, getRaw, getManyRaw, set, delete, deleteMany, clear, has, hasMany, disconnect) from this.opts.store to this._store.
    • Updated compression property access in get and getRaw from this.opts.compression to this._compression.
  • core/keyv/test/test.ts
    • Updated test assertions to use keyv.namespace instead of keyv.opts.namespace.
    • Modified the test for has to use keyv.store.has instead of keyv.opts.store.has.
    • Adjusted tests related to ttl to use keyv.ttl instead of keyv.opts.ttl.
Activity
  • No specific activity (comments, reviews, or progress updates) was provided in the context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a nice refactoring that removes the public opts property from the Keyv class, replacing it with private backing fields and public accessors. This is a great improvement for encapsulation and code clarity. The changes are consistently applied, and the tests have been updated to reflect the new API. I have one suggestion to further improve maintainability by centralizing a repeated type cast.

@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a898742) to head (53c6e80).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1843   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           32        32           
  Lines         2432      2432           
  Branches       447       448    +1     
=========================================
  Hits          2432      2432           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Introduce a private `_adapter` getter that returns `this._store` cast
to `KeyvStoreAdapter`, replacing repeated inline casts throughout the
class methods.

https://claude.ai/code/session_016DDrEfvCF1pcgvoX4hdkf7
…test

Rename private getter from `_adapter` to `_storeAdapter` for clarity.
Add test coverage for the new `emitErrors` getter/setter to restore
coverage to pre-change levels (99.41% lines).

https://claude.ai/code/session_016DDrEfvCF1pcgvoX4hdkf7
Type `_store` directly as `KeyvStoreAdapter` so methods can use it
without casts. Only the default value (`new Map() as any`) and the
constructor's `Symbol.iterator` check need targeted casts. Removes
the `_storeAdapter` getter since it's no longer needed.

https://claude.ai/code/session_016DDrEfvCF1pcgvoX4hdkf7
@jaredwray jaredwray force-pushed the claude/remove-opts-property-iOI7I branch from b1b897e to 53c6e80 Compare February 15, 2026 23:48
@jaredwray jaredwray merged commit 4029612 into main Feb 15, 2026
10 checks passed
@jaredwray jaredwray deleted the claude/remove-opts-property-iOI7I branch February 15, 2026 23:54
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