prefer-type-fest-asyncify
Prefer Asyncify from type-fest over manual asyncified function-type wrappers.
This rule lives only in the experimental preset and reports without autofixing.
Targeted pattern scopeโ
This rule focuses on two narrow shapes:
- direct function-type wrappers of the form
(...args: Parameters<Function>) => Promise<Awaited<ReturnType<Function>>> SetReturnType<Function, Promise<Awaited<ReturnType<Function>>>>compositions
It intentionally skips broader promise-returning wrappers so the report signal stays specific to Asyncify.
What this rule reportsโ
This rule reports when all of the following are true:
- the wrapper keeps the original parameter list through
Parameters<Function>orSetReturnType<Function, ...> - the new return type is exactly
Promise<Awaited<ReturnType<Function>>>
The rule is currently report-only. It does not autofix or suggest a replacement yet.
Why this rule existsโ
Asyncify<Function> communicates the intent directly.
- Readers can tell immediately that a synchronous function type is being boxed into an async equivalent.
- The helper avoids repeating the
Promise<Awaited<ReturnType<...>>>boilerplate. - It composes naturally with other Type-Fest function helpers.
โ Incorrectโ
type AsyncVersion<Function_ extends (...arguments_: any[]) => any> =
(...arguments_: Parameters<Function_>) =>
Promise<Awaited<ReturnType<Function_>>>;
โ Correctโ
import type {Asyncify} from "type-fest";
type AsyncVersion<Function_ extends (...arguments_: any[]) => any> =
Asyncify<Function_>;
Behavior and migration notesโ
- This rule intentionally overlaps with
SetReturnTypeonly for the exact asyncified return shape, and it takes precedence there. - It reports both the raw wrapper and the
SetReturnType<..., Promise<Awaited<ReturnType<...>>>>composition. - It ignores non-async
SetReturnTypeusage.
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 the explicit wrapper signature or if you want to reserve Asyncify for only a subset of wrapper types.
Package documentationโ
TypeFest package documentation:
Source file: source/asyncify.d.ts
import type {Asyncify} from "type-fest";
type AsyncVersion<Function_ extends (...arguments_: any[]) => any> =
Asyncify<Function_>;
Rule catalog ID: R093