@@ -167,7 +167,7 @@ class Stack {
167
167
/**
168
168
* Promise representing an in-progress {@link LRUCache#fetch} call
169
169
*/
170
- export type BackgroundFetch < V > = Promise < V | undefined | void > & {
170
+ export type BackgroundFetch < V > = Promise < V | undefined > & {
171
171
__returned : BackgroundFetch < V > | undefined
172
172
__abortController : AbortController
173
173
__staleWhileFetching : V | undefined
@@ -500,7 +500,7 @@ export namespace LRUCache {
500
500
key : K ,
501
501
staleValue : V | undefined ,
502
502
options : FetcherOptions < K , V , FC >
503
- ) => Promise < V | void | undefined > | V | void | undefined
503
+ ) => Promise < V | undefined | void > | V | undefined | void
504
504
505
505
/**
506
506
* Options which may be passed to the {@link LRUCache} constructor.
@@ -1868,9 +1868,9 @@ export class LRUCache<K extends {}, V extends {}, FC = unknown> {
1868
1868
}
1869
1869
1870
1870
const cb = (
1871
- v : V | void | undefined ,
1871
+ v : V | undefined ,
1872
1872
updateCache = false
1873
- ) : V | undefined | void => {
1873
+ ) : V | undefined => {
1874
1874
const { aborted } = ac . signal
1875
1875
const ignoreAbort = options . ignoreFetchAbort && v !== undefined
1876
1876
if ( options . status ) {
@@ -1943,12 +1943,12 @@ export class LRUCache<K extends {}, V extends {}, FC = unknown> {
1943
1943
}
1944
1944
1945
1945
const pcall = (
1946
- res : ( v : V | void | undefined ) => void ,
1946
+ res : ( v : V | undefined ) => void ,
1947
1947
rej : ( e : any ) => void
1948
1948
) => {
1949
1949
const fmp = this . #fetchMethod?.( k , v , fetchOpts )
1950
1950
if ( fmp && fmp instanceof Promise ) {
1951
- fmp . then ( v => res ( v ) , rej )
1951
+ fmp . then ( v => res ( v === undefined ? undefined : v ) , rej )
1952
1952
}
1953
1953
// ignored, we go until we finish, regardless.
1954
1954
// defer check until we are actually aborting,
@@ -1958,7 +1958,7 @@ export class LRUCache<K extends {}, V extends {}, FC = unknown> {
1958
1958
! options . ignoreFetchAbort ||
1959
1959
options . allowStaleOnFetchAbort
1960
1960
) {
1961
- res ( )
1961
+ res ( undefined )
1962
1962
// when it eventually resolves, update the cache.
1963
1963
if ( options . allowStaleOnFetchAbort ) {
1964
1964
res = v => cb ( v , true )
@@ -1969,7 +1969,7 @@ export class LRUCache<K extends {}, V extends {}, FC = unknown> {
1969
1969
1970
1970
if ( options . status ) options . status . fetchDispatched = true
1971
1971
const p = new Promise ( pcall ) . then ( cb , eb )
1972
- const bf = Object . assign ( p , {
1972
+ const bf : BackgroundFetch < V > = Object . assign ( p , {
1973
1973
__abortController : ac ,
1974
1974
__staleWhileFetching : v ,
1975
1975
__returned : undefined ,
@@ -2020,7 +2020,7 @@ export class LRUCache<K extends {}, V extends {}, FC = unknown> {
2020
2020
: FC extends undefined | void
2021
2021
? LRUCache . FetchOptionsNoContext < K , V >
2022
2022
: LRUCache . FetchOptionsWithContext < K , V , FC >
2023
- ) : Promise < void | V >
2023
+ ) : Promise < undefined | V >
2024
2024
// this overload not allowed if context is required
2025
2025
fetch (
2026
2026
k : unknown extends FC
@@ -2033,11 +2033,11 @@ export class LRUCache<K extends {}, V extends {}, FC = unknown> {
2033
2033
: FC extends undefined | void
2034
2034
? LRUCache . FetchOptionsNoContext < K , V >
2035
2035
: never
2036
- ) : Promise < void | V >
2036
+ ) : Promise < undefined | V >
2037
2037
async fetch (
2038
2038
k : K ,
2039
2039
fetchOptions : LRUCache . FetchOptions < K , V , FC > = { }
2040
- ) : Promise < void | V > {
2040
+ ) : Promise < undefined | V > {
2041
2041
const {
2042
2042
// get options
2043
2043
allowStale = this . allowStale ,
0 commit comments