-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TS2367: This condition will always return 'false' #29822
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
Comments
Relevant comment and issue here. |
Hmm, this is a bit different than #9998 (comment) though since |
I don't know if TypeScript distinguishes properties obtained literally or via getters, but I'm not sure it would help much. Even if that information was made available the choices are between performing some inline effect analysis, assuming all getters are mutable, or assuming all getters are immutable. |
That’s true, I guess it comes down to real-world tradeoffs as discussed in #9998 (is it bad I know this issue number by heart?). I guess what I find surprising is that |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
sorry, but this is a mistake. Getter properties should not be narrowed. How do you "convert" to a function call if I can't invoke the property as a function Adding a simple local function wrapper around the call to the property "tricks" the compile and it now compiles... insane!
if I replace with the following, the compiler is now happy
As properties are function under the hood, #9998 should function behaviour to properties. |
Trade-offs exist. Trying to act as if things don't have a more common and less common behavior is just nihilism and doesn't make the type system more usable. For any given value that might be stable or might not be, TS has to make an assumption one way or the other. For functions, assuming instability is going to be correct much more often than it's wrong. For properties, assuming stability is going to be correct much more often than it's wrong. |
TypeScript Version: 3.3.3
Search Terms: TS2367
Expected behavior:
No compilation errors
Actual behavior:
error TS2367: This condition will always return 'false' since the types '"A"' and '"B"' have no overlap.
Playground Link:
Here
The text was updated successfully, but these errors were encountered: