Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider @typescript-eslint/explicit-function-return-type #13

Open
sybereal opened this issue Sep 16, 2022 · 0 comments
Open

Consider @typescript-eslint/explicit-function-return-type #13

sybereal opened this issue Sep 16, 2022 · 0 comments
Assignees

Comments

@sybereal
Copy link
Collaborator

https://typescript-eslint.io/rules/explicit-function-return-type

It's an extremely strict and potentially excessive requirement, but it brings a lot of value. The key benefit is that mistakes pertaining to a function's return type cause errors within the function, and not at the usage site, which might be in an entirely different file or different package even. This is especially relevant when accidentally using (slightly) inconsistent return types. TypeScript won't care and just infer the return type as the union of all return statements' types, but users of the function will be very confused.

A less strict alternative is explicit-module-boundary-types, which reduces the requirement to exported values and functions, retaining the lion's share of the value the rule brings, while reducing friction for internal helper functions, callbacks, etc..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants