prefer-type-fest-set-return-type
Prefer SetReturnType from type-fest over direct function-type wrappers built from Parameters.
This rule lives only in the experimental preset and reports without autofixing.
Targeted pattern scopeโ
This rule focuses on direct function-type wrappers of the form:
(...args: Parameters<Function>) => Result
It intentionally skips the async-specific Promise<Awaited<ReturnType<Function>>> shape so the more specific prefer-type-fest-asyncify rule can handle that case.
What this rule reportsโ
This rule reports function types when all of the following are true:
- the function type has exactly one rest parameter
- that rest parameter is typed as
Parameters<Function> - the return type is not the original
ReturnType<Function> - the return type is not the
AsyncifyshapePromise<Awaited<ReturnType<Function>>>
The rule is currently report-only. It does not autofix or suggest a replacement yet.
Why this rule existsโ
SetReturnType<Function, Result> states the transformation directly.
- Readers can see that only the return type changes.
- The helper is easier to reuse consistently across wrapper types.
- It avoids repeating the same
Parameters<...>boilerplate in local helper types.
โ Incorrectโ
type WithResult<Function_ extends (...arguments_: any[]) => any, Result> =
(...arguments_: Parameters<Function_>) => Result;
โ Correctโ
import type {SetReturnType} from "type-fest";
type WithResult<Function_ extends (...arguments_: any[]) => any, Result> =
SetReturnType<Function_, Result>;
Behavior and migration notesโ
- This rule targets the narrow rest-parameter form
(...args: Parameters<F>) => R. - It ignores ordinary handwritten function types with explicit parameters.
- It intentionally defers asyncified wrappers to
prefer-type-fest-asyncify.
ESLint flat config exampleโ
import typefest from "eslint-plugin-typefest";
export default [typefest.configs.experimental];
When not to use itโ
Disable this rule if your team prefers to spell out the wrapper function type explicitly or if you need a custom helper name for return-type rewrites.
Package documentationโ
TypeFest package documentation:
Source file: source/set-return-type.d.ts
import type {SetReturnType} from "type-fest";
type Wrapped<Function_ extends (...arguments_: any[]) => any> =
SetReturnType<Function_, string>;
Rule catalog ID: R092