true ||
leads to "Object possibly 'undefined'"
#35238
Labels
Duplicate
An existing issue was already created
true ||
leads to "Object possibly 'undefined'"
#35238
TypeScript Version: Nightly (as of date of issue creation)
Search Terms:
Code
Expected behavior:
Compiles with no errors
Actual behavior:
"Object is 'undefined'" on
x
in the statementreturn true || x.bar
This is especially weird because if you remove the
true ||
so you just havereturn x.bar
, there is no error, and if you move the extra condition to the end so you havereturn x.bar || true
there is also no error.Playground Link: http://www.typescriptlang.org/play/index.html?ts=Nightly#code/JYOwLgpgTgZghgYwgAgGIHt3IN4FgBQyRyARnFAPwBcpmANhHCAQL4EwCuICYw6IySAGcwACgAeNDFgA+yLgBMIMUBAUBKHAWLJgMZKICE4igDoyUTXkI7iUCGA5RmNom1fJ7j54KgcUMnLi5uSsQA
The text was updated successfully, but these errors were encountered: