File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -52,21 +52,21 @@ export function createCancelablePromise<T>(callback: (token: CancellationToken)
52
52
53
53
export function raceCancellation < T > ( promise : Promise < T > , token : CancellationToken ) : Promise < T | undefined > ;
54
54
export function raceCancellation < T > ( promise : Promise < T > , token : CancellationToken , defaultValue : T ) : Promise < T > ;
55
- export function raceCancellation < T > ( promise : Promise < T > , token : CancellationToken , defaultValue ?: T ) : Promise < T > {
56
- return Promise . race ( [ promise , new Promise < T > ( resolve => token . onCancellationRequested ( ( ) => resolve ( defaultValue ) ) ) ] ) ;
55
+ export function raceCancellation < T > ( promise : Promise < T > , token : CancellationToken , defaultValue ?: T ) : Promise < T | undefined > {
56
+ return Promise . race ( [ promise , new Promise < T | undefined > ( resolve => token . onCancellationRequested ( ( ) => resolve ( defaultValue ) ) ) ] ) ;
57
57
}
58
58
59
- export function raceTimeout < T > ( promise : Promise < T > , timeout : number , onTimeout ?: ( ) => void ) : Promise < T > {
60
- let promiseResolve : ( ( ) => void ) | undefined = undefined ;
59
+ export function raceTimeout < T > ( promise : Promise < T > , timeout : number , onTimeout ?: ( ) => void ) : Promise < T | undefined > {
60
+ let promiseResolve : ( ( value : T | undefined ) => void ) | undefined = undefined ;
61
61
62
62
const timer = setTimeout ( ( ) => {
63
- promiseResolve ?.( ) ;
63
+ promiseResolve ?.( undefined ) ;
64
64
onTimeout ?.( ) ;
65
65
} , timeout ) ;
66
66
67
67
return Promise . race ( [
68
68
promise . finally ( ( ) => clearTimeout ( timer ) ) ,
69
- new Promise < T > ( resolve => promiseResolve = resolve )
69
+ new Promise < T | undefined > ( resolve => promiseResolve = resolve )
70
70
] ) ;
71
71
}
72
72
You can’t perform that action at this time.
0 commit comments