Open
Description
π Search Terms
boolean literal type true false assign expression
π Version & Regression Information
- This changed between versions 4.1.5 and 4.2.3
- Not sure but feat(40197): No "did you mean to call" error when invocation is part of a logical expressionΒ #40260 could be the reason
β― Playground Link
π» Code
declare let someBool: boolean;
let okay = true;
let weird = someBool || true;
π Actual behavior
weird
is assigned the type true
, whereas okay
is of type boolean
.
π Expected behavior
Both variables have the type boolean
.
Additional information about the issue
Stumbled upon this while writing facebook/react#33399.
Very unexpected and confusing behavior, I highly doubt it is intended. Couldn't find anything explaining the change in the release notes for TypeScript 4.2, so pretty sure it's an unwanted regression. Please correct me if I'm wrong.