use-unknown-in-catch-callback-variable
Added in v0.1.4Configuration
Rule Details
Enforce typing the rejection callback parameter of .catch() and .then() as unknown. Similar to how catch clause variables should be typed as unknown (since any value can be thrown), Promise rejection callback parameters should also be typed as unknown. This prevents unsafe property accesses and assumptions about the shape of the rejection reason.
The rule checks .catch(callback) and .then(onFulfilled, onRejected) calls on thenable types and flags the rejection callback parameter when it is not typed as unknown.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Differences from Upstream
Rslint avoids evaluating array and string spreads with the default iterator when the corresponding prototype may have been modified. typescript-eslint v8.67.0 can still use the default iterator and mistake a fulfillment callback for a rejection callback in this situation:
The call executes then, so Rslint does not suggest changing value to unknown.
The same safeguard applies to a modified String.prototype[Symbol.iterator].