-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Suggestion
π Search Terms
- uncalled function
- check
- statement
β Suggestion
Today TS can detect uncalled functions that appear in conditionals. I propose also extending this to detect uncalled functions that appear an an expression where the result is unused
π Motivating Example
export interface Foo {
doImportantStuff(): void;
}
declare const foo: Foo;
if (foo.doImportantStuff) { // This one is detected
...
}
[foo].forEach(x => foo.doImportantStuff); // Mistake here. The user forgot to call `doImportantStuff`
π» Use Cases
This was inspired by a real world bug in the VS Code codebase. The case with forEach
shows the problem we ran into
Off the top of my head, I don't think there would be false positives but may need some more thought to make sure
Related issues
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript