▲ | moritzwarhier 2 days ago | |
I admit I didn't read all of your commment. But is
different from
? Is it a type-level construct to express a predicate like
?In any case, optional types containing boolean values are definitively an anti-pattern. And in cases where it's prudent to check for the "presence" of a property containing a
, while using coercion, it does not make sense to distinguish false from "falsy".TypeScript's dynamic narrowing has become pretty comprehensive when it comes to this kind of issue. Still, Option<Boolean> types are bad in most contexts I think, especially in languages like JS. Instead of using boolean | undefined , I much prefer explicit defaults (parameters) or properties being declared every time (data). | ||
▲ | jerf a day ago | parent [-] | |
Some<false> was written as the value; the type of that value would be Option<(Some Sort Of Still-A-Boolean)>. I have to write it that way because the entire conversation is about the language not having a boolean, so you can't properly write Option<bool> as a type in that language, which is why I mention it may actually be JSON::boolean or something, as well as several other booleans in other similar situations. My point is that you'll still end up with booleans in them though because you'll still have to have representations of other thing's booleans anyhow. |