-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Failed check on function in if clause #19026
Comments
There are limits to things like call flow analysis, and this would be one of them. While it might be potentially a logic error, what is a real world use case where this would occur. CFA comes at a cost, and if this is not a common logic error, it is unlikely for it to be added to the compiler. |
But I really did take a very long time to find this error in real world. As you can see, I just made a example. |
And Why |
A simplified example is always good, but again, that is not very realistic or sensible code. If you provided an example that was more realistic, then it might help identify how TypeScript could help in statically identifying issues. There are trade-offs with CFA (see #9998). This would require the ability to describe the return types of functions in truthy and un-truthy values to be evaluated at run time to produce the same error. While On the other hand, providing more than one statement to an |
This is unrelated to Math.floor(1.2), 2; // No error
1, 2; // Error Note that the error message says "and has no side effects". TypeScript doesn't track what functions have side effects, so this error will only happen for an expression that obviously has no side effects such as |
Thx,I got it. |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.5.3
Code
Expected behavior:
error TS2695: Left side of comma operator is unused and has no side effects.
Actual behavior:
Nothing happened.
But can get error like this.
The text was updated successfully, but these errors were encountered: