So in a language with nullable types, are you against a boolean ever being nullable? Null means “empty, missing info”. Let’s say we have role
variable with a enum type of possible roles. It could still reasonably be nullable, because in some scenarios you don’t know the role yet, like before log in.
In any use case where we need to store some boolean, it’s a common occurrence that we don’t have the data and it’s null. It would be overkill to use an enum with True
, False
, NoData
for these cases, where there is already a language feature made just for that, nullable values.
I’ve never used TypeScript, just writing from experience in other languages.
Depends on your requirements.
If the admin status needs to be checked in a database, but most actions don’t require authentication at all, it’s pointless to waste resources checking and it would be left null until the first action that needs the information checks it and fills it in as true or false.