11type IsFunctionReturnTypePromise < T extends ( ...args : any [ ] ) => any > =
2- ReturnType < T > extends Promise < infer U > ? true : false
2+ ReturnType < T > extends Promise < infer _U > ? true : false
33
44type ExactReturnType < T extends ( ...args : any [ ] ) => any > = T extends ( ...args : any [ ] ) => infer R ? R : never
55
@@ -17,7 +17,7 @@ class TryResult<T, E extends Error | null> {
1717 }
1818}
1919
20- type MutuallyExclusiveTryResult < T , E extends Error | null > = TryResult < T , null > | TryResult < null , E >
20+ export type ResguardResult < T , E extends Error | null > = TryResult < T , null > | TryResult < null , E >
2121
2222type ErrorClass = new ( ...args : any [ ] ) => Error
2323
@@ -29,22 +29,22 @@ export function resguard<_T = never, E extends ErrorClass = ErrorClass>(
2929export function resguard < T , E extends ErrorClass = ErrorClass > (
3030 func : ( ) => Promise < T > ,
3131 _errorType ?: E ,
32- ) : Promise < MutuallyExclusiveTryResult < T , InstanceType < E > > >
32+ ) : Promise < ResguardResult < T , InstanceType < E > > >
3333
3434export function resguard < T , E extends ErrorClass = ErrorClass > (
3535 func : ( ) => T ,
3636 _errorType ?: E ,
37- ) : MutuallyExclusiveTryResult < T , InstanceType < E > >
37+ ) : ResguardResult < T , InstanceType < E > >
3838
3939export function resguard < T , E extends ErrorClass = ErrorClass > (
4040 promise : Promise < T > ,
4141 _errorType ?: E ,
42- ) : Promise < MutuallyExclusiveTryResult < T , InstanceType < E > > >
42+ ) : Promise < ResguardResult < T , InstanceType < E > > >
4343
4444export function resguard < T , E extends ErrorClass = ErrorClass > (
4545 promiseOrFunction : ( ( ) => ( T | Promise < T > ) ) | Promise < T > ,
4646 _errorType ?: E ,
47- ) : MutuallyExclusiveTryResult < T , InstanceType < E > > | Promise < MutuallyExclusiveTryResult < T , InstanceType < E > > > {
47+ ) : ResguardResult < T , InstanceType < E > > | Promise < ResguardResult < T , InstanceType < E > > > {
4848 try {
4949 if ( promiseOrFunction instanceof Promise ) {
5050 return promiseOrFunction
@@ -68,7 +68,7 @@ export function resguard<T, E extends ErrorClass = ErrorClass>(
6868 }
6969}
7070
71- export function resguardFn < T extends ( ...args : any [ ] ) => any , E extends ErrorClass = ErrorClass , U = any > (
71+ export function resguardFn < T extends ( ...args : any [ ] ) => any , E extends ErrorClass = ErrorClass , _U = any > (
7272 func : T ,
7373 _errorType ?: E ,
7474) : ( ...args : Parameters < T > ) =>
0 commit comments