Repository navigation
Apply uncalled function checks to ternaries #36048
Copy link
Copy link
Closed
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScriptUpdate Docs on Next ReleaseIndicates that this PR affects docsIndicates that this PR affects docs
Milestone
Description
Activity
- addedExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript
on Jan 7, 2020 RyanCavanaugh commented
on Jan 7, 2020 MemberMore actionsSeems reasonable; we'd have to assess for breakage but I suspect this would turn out well
Reacted by David Blass, Christopher Kiss and Titian Cernicova-Dragomirdragomirtitian commented
on Jan 21, 2020 ContributorMore actionsRyan Cavanaugh (@RyanCavanaugh) Are you taking PRs on this one?
Reacted by Daniel Rosenwasser- changed the title
[-]Apply TS2774 to ternaries[/-][+]Apply uncalled function checks to ternaries[/+]on Jan 21, 2020 - addedEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do this
on Jan 21, 2020 DanielRosenwasser commented
on Jan 21, 2020 MemberMore actionsYes
Reacted by Titian Cernicova-Dragomir and David Blass- addedExperimentation NeededSomeone needs to try this out to see what happensSomeone needs to try this out to see what happens
on Jan 21, 2020 DanielRosenwasser commented
on Jan 28, 2020 MemberMore actionsJust assigning Nathan Shively-Sanders (@sandersn) so that we can follow up on the PR for 3.9 sooner rather than later.
- addedBreaking ChangeWould introduce errors in existing codeWould introduce errors in existing code
on Feb 20, 2020 - addedUpdate Docs on Next ReleaseIndicates that this PR affects docsIndicates that this PR affects docsand removedExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsExperimentation NeededSomeone needs to try this out to see what happensSomeone needs to try this out to see what happens
on Feb 20, 2020 DanielRosenwasser commented
on Feb 20, 2020 MemberMore actionsThanks Oleksandr Tarasiuk (@a-tarasyuk)!
Metadata
Metadata
Assignees
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScriptUpdate Docs on Next ReleaseIndicates that this PR affects docsIndicates that this PR affects docs
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: