You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uncalled Function Checks don't check negative condition #34815
Very much agree with this. In our code, we just got bit by
if(!nock.isActive){nock.activate()}
In general, I would usually not intentionally want !foo, and if I did want to do something like that, I would do foo === undefined. Even more generally, I would personally disallow coercion from function to boolean completely. Forcing devs to write foo === undefined would make it clear what their intention is, and would force the dev to type foo as Function | undefined, if that's truly what they want.
There are many, many false positives turned up in that PR. Unless these were ~all good finds, I think this is appropriately left still in "awaiting more feedback" state
The tool for finding false positives is super neat. It makes sense to me to not merge this -- I followed ~20 links and I think this was the only legitimate bug I found (it should have an await). The rest were all just undefined checks on things that the typings say should always be defined.
I'm happy to close out that PR (or have you close it). Whatever works for you.
Activity
brandon-leapyear commentedon Feb 17, 2021
✨ This is an old work account. Please reference Brandon Chinn (@brandonchinn178) for all future communication ✨
Very much agree with this. In our code, we just got bit by
In general, I would usually not intentionally want
!foo, and if I did want to do something like that, I would dofoo === undefined. Even more generally, I would personally disallow coercion from function to boolean completely. Forcing devs to writefoo === undefinedwould make it clear what their intention is, and would force the dev to typefooasFunction | undefined, if that's truly what they want.AlexMarkUSDS commentedon Jan 21, 2024
This bit me last week in one of the codebases I maintain. I also see that it's bitten a number of others:
There's relevant info in:
Daniel Rosenwasser (@DanielRosenwasser), would the TS team accept a contribution for this? I've optimistically opened a PR at #57114
RyanCavanaugh commentedon Jan 23, 2024
There are many, many false positives turned up in that PR. Unless these were ~all good finds, I think this is appropriately left still in "awaiting more feedback" state
AlexMarkUSDS commentedon Jan 24, 2024
The tool for finding false positives is super neat. It makes sense to me to not merge this -- I followed ~20 links and I think this was the only legitimate bug I found (it should have an await). The rest were all just undefined checks on things that the typings say should always be defined.
I'm happy to close out that PR (or have you close it). Whatever works for you.