Closed
Description
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.
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).
Link to the rule's documentation
https://typescript-eslint.io/rules/explicit-function-return-type/
Description
Right now the rule will error on IIFE's (immediately invoked function expressions).
IIFEs really shouldn't be covered by the rule because there's no "contract" that needs to be enforced between callers - there's no external callers at all - just one immediate, inline callsite.
In most IIFE cases you are just using an IIFE to wrap-up some logic for a specific variable to be initialised with a value.
By forcing you to annotate an IIFE's return essentially you're forcing someone to annotate the variable declaration explicitly (which isn't what the rule is about!)
We should have an option that allows the rule to ignore IIFEs.
Fail
function foo() {}
const bar = () => {}
const baz = function () {}
Pass
const bar = (() => {})();
const baz = (function () {})();
Additional Info
No response