You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The return type for fetch in each of the current two overloads is Promise<undefined | V>.
However, fetch should always resolve to V except when certain options are set (e.g. ignoreFetchAbort and allowStaleOnFetchAbort).
As the return type is now, callers must resort to solutions like ! to tell TypeScript type checking that the value won't be undefined:
constvalue: V|undefined=awaitcache.fetch(key);
constvalue: V=(awaitcache.fetch(key))!;
Is it possible to add additional overrides for fetch to define return a return type of Promise<V> for whenever the LRUCache instance wasn't constructed with options that would allow resolving to undefined? If that is too complicated or otherwise isn't feasible at this time, then what about adding an alternative method that always fetches or throws independent of those options which never resolves to undefined (e.g. fetchOrError)?
constvalue: V=awaitcache.fetch(key);
or
constvalue: V=awaitcache.fetchOrError(key);
The text was updated successfully, but these errors were encountered:
The return type for
fetch
in each of the current two overloads isPromise<undefined | V>
.However,
fetch
should always resolve toV
except when certain options are set (e.g.ignoreFetchAbort
andallowStaleOnFetchAbort
).As the return type is now, callers must resort to solutions like
!
to tell TypeScript type checking that the value won't beundefined
:Is it possible to add additional overrides for
fetch
to define return a return type ofPromise<V>
for whenever theLRUCache
instance wasn't constructed with options that would allow resolving toundefined
? If that is too complicated or otherwise isn't feasible at this time, then what about adding an alternative method that always fetches or throws independent of those options which never resolves toundefined
(e.g.fetchOrError
)?or
The text was updated successfully, but these errors were encountered: