New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncalled function checks only works with single conditional #35584
Comments
This is the intended scoping of the check to reduce over-reported errors. |
@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? |
We don't have "Just so you know" warnings and don't intend to add them |
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 import * as fs from 'fs';
fs.stat('/path/to/file', function(err, stats) {
if (stats.isDirectory && !err) {
}
}); At the moment if we were to do this the error around Do you think it should still be reported in this scenario? |
I may have missed any checks for whether this comes up in conditionals, |
We can try expanding the set of things checked and see what comes up. |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
@DanielRosenwasser How deep do we want to go here? Any sort of arbitrary expression with interface StatsBase<T> {
isDirectory(): boolean;
time: number
}
function A(err: any, stats: StatsBase<any>) {
if (stats.isDirectory || stats.isDirectory()) { // should be error ?
}
}
function B(err: any, stats: StatsBase<any>) {
if (stats.isDirectory && stats.isDirectory()) { // should be ok
}
}
function C(err: any, stats: StatsBase<any>) {
if (!stats.isDirectory || stats.isDirectory()) { // should be ok
}
} |
Can @mshivaku99 and I work on this (we have a class assignment to help fix a bug in an open-source project) |
@sandersn I am doing open-source for this week and would like to help resolve |
@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. |
@sandersn is there anyone I can contact to ask |
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.
|
Just opened a pull request (#42835) that attempts to address the two problems mentioned in this thread. Feel free to check it out |
TypeScript Version: 3.8.0-dev.20191207
Search Terms:
Code
With strict null checks enabled:
Expected behavior:
Accesses to
isFile
andisDirectory
are reported as errors since these are actually functionsActual behavior:
No errors.
Errors are only reported when there is a single conditional
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: