Apply uncalled function checks to ternaries #36048
Labels
Breaking Change
Would introduce errors in existing code
Effort: Moderate
Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".
Help Wanted
You can do this
Suggestion
An idea for TypeScript
Update Docs on Next Release
Indicates that this PR affects docs
Milestone
Search Terms
ts2774 ternary condition error function called uncalled
Suggestion
TS2774 (implemented in #32802), i.e. the
"This condition will always return true since the function is always defined. Did you mean to call it instead?"
error, provides a helpful hint for developers referencing a function in an if statement without calling it. However, the same check doesn't apply to ternaries, which is missing an opportunity to save some debug time and counterintuitive for devs who know about TS2774. I propose reusing TS2774 for developers who forget to call a function in a ternary.Examples
Now:
If this suggestion is adopted:
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: