String union types narrowed to falsy should narrow string to "" #45329
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Bug Report
🔎 Search Terms
string truthy falsy narrow literal empty
🕗 Version & Regression Information
This is a crashThis changed between versions ______ and _______I was unable to test this on prior versions because _______⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Inside the narrowed block,
value
should befalse | ""
, because no other string value is falsy.🙂 Expected behavior
It's the more general
false | string
instead.This was a hard issue to search for; #41503, #33878, and #31156 seemed related but not duplicate to me.
Shoutout to RyanCavanaugh for sending me a code snippet that looked like this -- no good deed goes unpunished in the issue tracker 😄
The text was updated successfully, but these errors were encountered: