⚡️ Performance: [no-misused-promises] computes void-returning parameters for calls with no arguments
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
- If I used AI assistance to prepare this issue, I have reviewed and followed the AI Contribution Policy.
Relevant Package
eslint-plugin
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Description
no-misused-promises runs checkArguments on every CallExpression and NewExpression. It computes voidFunctionArguments first, which asks the checker for the callee's type, its signatures, and each parameter's type, and only then loops over node.arguments to report promise-returning ones.
A call with no arguments can never report, but it still runs all of those type queries. Returning early when node.arguments.length === 0 would skip them without changing the rule's behavior.
Suggestion: shall we do this little optimization? I sent #12923 as a draft for reference.
Additional Info
Found while profiling the experimental TypeScript 7 native backend in #12803, where each type query is a round trip to another process. On a 1024-file project with recommendedTypeChecked, it removes ~1,000 of ~6,200 remaining round trips and ~59 ms of rule time.
With classic in-process TypeScript on the same project, the rule's own time drops from ~21 ms to ~8 ms.
Source: typescript-eslint/typescript-eslint