Skip to content

Detect uncalled function statements #47698

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

Open
mjbvz opened this issue Feb 2, 2022 · 0 comments
Open

Detect uncalled function statements #47698

mjbvz opened this issue Feb 2, 2022 · 0 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Feb 2, 2022

Suggestion

πŸ” Search Terms

  • uncalled function
  • check
  • statement

⭐ Suggestion

Today TS can detect uncalled functions that appear in conditionals. I propose also extending this to uncalled functions that appear as statements

πŸ“ƒ Motivating Example

function doImportantStuff() { }

doImportantStuff;  // Mistake here. The user forgot to call the func

if (doImportantStuff) { // This one is detected today

}

πŸ’» Use Cases

This can help catch a common programming mistake. As long as the function being checked has a const binding and is always a function type, I don't think there are cases where you actually want to write doImportantStuff; as a statement

Related issues

@RyanCavanaugh RyanCavanaugh added the Suggestion An idea for TypeScript label Feb 2, 2022
@RyanCavanaugh RyanCavanaugh added the Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature label Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants