Skip to content

Commit 954e640

Browse files
author
João Dias
committed
fix(callIfExists): generic constraint does not accomodate specific argument types
1 parent 9e94c0d commit 954e640

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/functions/utilities/call-if-exists.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ import { isFunction } from "../typed";
2727
* callIfExists(undefined); // => undefined
2828
* callIfExists(null); // => undefined
2929
*/
30-
export function callIfExists<T extends (...args: unknown[]) => ReturnType<T>>(
30+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
31+
export function callIfExists<T extends (...args: any[]) => any>(
3132
callback: T | undefined | null,
3233
...args: Parameters<T>
3334
): ReturnType<T> | undefined {
3435
if (isFunction(callback)) {
35-
return callback(...args);
36+
return callback?.(...args);
3637
}
3738
}

0 commit comments

Comments
 (0)