-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow cache.set(x, undefined)
to delete the cached item
#26
Conversation
Co-authored-by: Federico <me@fregante.com>
Thanks for the PR! This is a breaking change and also something that I had initially specifically avoided doing, so I'll probably wait just in case there's a reason not to do it. |
Maybe because it means |
I think the reasoning was that But also, yes, both I guess the former more than the latter. The first could throw an error though, at least to avoid using |
Can you add a |
Done. Also added a test to cover the new case. |
Co-authored-by: Federico <me@fregante.com>
Thanks! I'm releasing this as a minor after all. The behavior it changes isn't that breaking. Passing |
@@ -68,18 +68,21 @@ async function get<TValue extends Value>(key: string): Promise<TValue | undefine | |||
} | |||
|
|||
async function set<TValue extends Value>(key: string, value: TValue, maxAge: TimeDescriptor = {days: 30}): Promise<TValue> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only issue here is that undefined
isn't accepted by the types
async function set<TValue extends Value>(key: string, value: TValue, maxAge: TimeDescriptor = {days: 30}): Promise<TValue> { | |
async function set<TValue extends Value>(key: string, value: TValue | undefined, maxAge: TimeDescriptor = {days: 30}): Promise<TValue> { |
I released a prerelease 4.3.0-0 if you want to try it in RGH in the original issue that discussed this
This is a very basic fix for the issue #25 discovered in refined-github/refined-github#3589.
Fixes #25