Closed FrancescElies closed 1 year ago
This sounds better suited as a linter rule instead of being part of the compiler. But I'd expect the false positives to be immensely.
you are right, closing, I'll bring this to a linter project we end up using, thanks
Suggestion
In pyright there is reportUnusedCallResult but I couldn't find anything similar in TypeScript: TSConfig Reference, please correct me if I missed it.
π Search Terms
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
A similar option to pyright's reportUnusedCallResult could be added and being disabled it's default state and maybe enabled with strict flag?
π Motivating Example
One reads this and wonders, why would one _getchichi here, chichi is not used anywhere.
π» Use Cases
Reminding the developer about unused call results makes it harder to see code like in the example above.
One problem I see with the proposal above is that there seems to be no convention in javascript for throwaway variables, but according to What is the equivalent of python's _ in javascript? - Stack Overflow and naming - What's the idiomatic name for a throwaway variable? - Software Engineering Stack Exchange
dummy, temp, trash, black_hole, garbage
seem to be widely used.After tsc complains about the code above one would be forced to either remove that call, assign the result and use it or assign it to a throwaway variable.