[Refactoring] Better typings for safeExec
This commit is contained in:
parent
22019bc86c
commit
be4c220228
@ -3,7 +3,11 @@ import { handleError } from './handleError';
|
|||||||
|
|
||||||
const SAFE_EXEC_ENABLED = !DEBUG_MORE;
|
const SAFE_EXEC_ENABLED = !DEBUG_MORE;
|
||||||
|
|
||||||
export default function safeExec(cb: Function, rescue?: (err: Error) => void, always?: NoneToVoidFunction) {
|
export default function safeExec<F extends AnyFunction>(
|
||||||
|
cb: F,
|
||||||
|
rescue?: (err: Error) => void,
|
||||||
|
always?: NoneToVoidFunction,
|
||||||
|
): ReturnType<F> | undefined {
|
||||||
if (!SAFE_EXEC_ENABLED) {
|
if (!SAFE_EXEC_ENABLED) {
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user