Skip to content

Why does the fetch function return void ? #302

@HuyAms

Description

@HuyAms

Hi,

I'm on version ^9.1.1

I try to use the fetch()function with Typescript. However, the return type is void | V. I expect it to return only the Value type only. The void type will break some of my TS.

Version 7.18return the value only without void

const cache = new LRUCache<string, string> ({
		max: 10,
		ttl: 1000 * 60 * 10, // 10 minutes
		allowStale: true,
		noDeleteOnFetchRejection: true,
		fetchMethod: async (cacheKey) => {

			return "some string"
}))

// I expect it returns string but it returns void | string. Why so?
const data = await cache.fetch("somekey") 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions