-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
unknown type is narrowed to {}
in strict equality condition since 4.8
#50567
Comments
Related: #50531 |
I mean, this actually makes total sense under long-standing narrowing rules plus the changes to |
Yeah, this one is way less weird at second glance. I turned on the ability to narrow straight from |
I'm going to hope this isn't reflected under conditional type distribution the same way |
Sorry, did I say “equivalent”? I meant ✌️EQUIVALENT✌️***™️ * NOT ACTUALLY EQUIVALENT |
Bug Report
🔎 Search Terms
narrowing, object type, unknown, unknown narrowing
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Even though we've clearly inferred that the
unknown
is literally the string"xyz"
, the compiler somehow thinks it is instead{}
.🙂 Expected behavior
Builds fine.
More info
You can see here that its specific to having the false-check at the start of the function.
Removing the
if(!value)
condition causes the code to compile as expected.So it seems that turns the
value
into{}
somehow.The text was updated successfully, but these errors were encountered: