Open
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