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 only works with single conditional #35584
Ryan Cavanaugh (@RyanCavanaugh) I can definitely appreciate the reduction in over-reported errors but do you think not having any error at all seems to defeat the purpose? Could there be a way to mention it once for a particular block of code?
I think I may be miscommunicating the scenario or misunderstanding your perspective. I'm hoping to receive the error for the one instance even if there are other conditionals.
For example here we accidentally don't call isDirectory as a function while having some other conditional with it.
At the moment if we were to do this the error around stats.isDirectory is not reported at all but if we remove the !err conditional it will report as expected.
Do you think it should still be reported in this scenario?
This is the intended scoping of the check to reduce over-reported errors.
I may have missed any checks for whether this comes up in conditionals, &&, and || - did we see too many problems on those? My hunch is that that'd be nothing but goodness.
Daniel Rosenwasser (@DanielRosenwasser) How deep do we want to go here? Any sort of arbitrary expression with boolean operators should be ok ? I think the interesting bit is when the condition both checks and uses the function:
interfaceStatsBase<T>{isDirectory(): boolean;time: number}functionA(err: any,stats: StatsBase<any>){if(stats.isDirectory||stats.isDirectory()){// should be error ?}}functionB(err: any,stats: StatsBase<any>){if(stats.isDirectory&&stats.isDirectory()){// should be ok }}functionC(err: any,stats: StatsBase<any>){if(!stats.isDirectory||stats.isDirectory()){// should be ok }}
@mykolao-wix yep anything in a milestone (such as Backlog) has been accepted. In this case, Experimentation Needed+Suggestion means that the proposed solution might not be workable, but we want to find out by looking at a real implementation.
Activity
RyanCavanaugh commentedon Dec 9, 2019
This is the intended scoping of the check to reduce over-reported errors.
clarkio commentedon Dec 9, 2019
Ryan Cavanaugh (@RyanCavanaugh) I can definitely appreciate the reduction in over-reported errors but do you think not having any error at all seems to defeat the purpose? Could there be a way to mention it once for a particular block of code?
RyanCavanaugh commentedon Dec 9, 2019
We don't have "Just so you know" warnings and don't intend to add them
clarkio commentedon Dec 9, 2019
I think I may be miscommunicating the scenario or misunderstanding your perspective. I'm hoping to receive the error for the one instance even if there are other conditionals.
For example here we accidentally don't call
isDirectoryas a function while having some other conditional with it.At the moment if we were to do this the error around
stats.isDirectoryis not reported at all but if we remove the!errconditional it will report as expected.Do you think it should still be reported in this scenario?
DanielRosenwasser commentedon Dec 10, 2019
I may have missed any checks for whether this comes up in conditionals,
&&, and||- did we see too many problems on those? My hunch is that that'd be nothing but goodness.RyanCavanaugh commentedon Dec 10, 2019
We can try expanding the set of things checked and see what comes up.
typescript-bot commentedon Dec 13, 2019
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
dragomirtitian commentedon Dec 26, 2019
Daniel Rosenwasser (@DanielRosenwasser) How deep do we want to go here? Any sort of arbitrary expression with
booleanoperators should be ok ? I think the interesting bit is when the condition both checks and uses the function:Playground Link
nityatammana commentedon Apr 2, 2020
Can mshivaku99 and I work on this (we have a class assignment to help fix a bug in an open-source project)
sandersn commentedon Oct 5, 2020
@mykolao-wix yep anything in a milestone (such as Backlog) has been accepted. In this case, Experimentation Needed+Suggestion means that the proposed solution might not be workable, but we want to find out by looking at a real implementation.
mkloouo commentedon Oct 6, 2020
Nathan Shively-Sanders (@sandersn) is there anyone I can contact to ask
src/compiler/checker.tsAPI questions?evmar commentedon Jan 28, 2021
We had a variant of this come up at Google in code like
I think the broader fix might be something around "expression is always true" when you do a boolean check on a non-optional method.
Playground repro
jonhue commentedon Feb 17, 2021
Just opened a pull request (#42835) that attempts to address the two problems mentioned in this thread. Feel free to check it out 🙂