Skip to content

script-utils/linters/eslint-rules/no-async-callback-to-unsafe-return

ESLint rule: no-async-callback-to-unsafe-return

Reports an error when an async function is passed as a callback argument to a function parameter whose return type is any or unknown. Because these types silently accept Promise<T>, the caller won’t await the result, leading to unhandled promise rejections at runtime.

Example:

// onClick(fn: (evt: MouseEvent) => any)
button.onClick(async () => {
await someFn(); // Unhandled rejection if someFn throws
});

@typescript-eslint/no-misused-promises only catches => void callbacks. This rule closes the gap for => any and => unknown callbacks.

VariableDescription
MESSAGE_IDMessage ID reported when an async function is passed as a callback to a parameter whose return type is any/unknown, risking an unhandled promise rejection.
noAsyncCallbackToUnsafeReturn