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
Related Issues: #20583
Note that this is about the true branch (&&), and that foo itself is narrowed down to never (not foo.foo).
Current workaround: Switch operands. Had to do this in quite a few places in my codebase.
The text was updated successfully, but these errors were encountered:
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Search Terms:
Type narrowing, 'in'
Code
Expected behavior:
No type error. Just because there is an additional property in a
Foo
, it should still have all props ofFoo
.Actual behavior:
Error: Property 'foo' does not exist on type 'never'
Playground Link:
https://www.typescriptlang.org/play/index.html#src=interface%20Foo%20%7B%20%0D%0A%20%20%20%20foo%3A%20boolean%0D%0A%7D%0D%0A%0D%0Ainterface%20Bar%20%7B%0D%0A%20%20%20%20bar%3A%20boolean%0D%0A%7D%0D%0A%0D%0Afunction%20isFooAndHasBar(foo%3A%20Foo)%3A%20foo%20is%20Foo%20%26%20Bar%20%7B%0D%0A%20%20%20%20return%20'bar'%20in%20foo%20%26%26%20foo.foo%3B%0D%0A%7D
Related Issues:
#20583
Note that this is about the
true
branch (&&
), and thatfoo
itself is narrowed down tonever
(notfoo.foo
).Current workaround: Switch operands. Had to do this in quite a few places in my codebase.
The text was updated successfully, but these errors were encountered: