Skip to content

Detect uncalled function statementsΒ #47698

Open
@mjbvz

Description

@mjbvz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions