I've got a background in Cognitive Science and Mathematics, taught myself web development and since 2018 I'm a freelance software engineer with a focus on web and mobile development.
Very nice series and article! I have two questions though:
In the first example of StringOrArray we definitely need it. Changing never to any there would falsely allow wrong things to happen.
But if I replace never with any in Field (your second example) or FieldExtended (your last example) it would all still be type safe.
So is it a form of convention to use never as the last not handled condition to be on the safe side?
I see that FieldExtended is basically the identity function with type checks. I can understand that a code editor might use such a function. But as an app developer, what would be a use-case for me to actually use something like FieldExtended?
Very nice series and article! I have two questions though:
StringOrArray
we definitely need it. Changingnever
toany
there would falsely allow wrong things to happen.But if I replace
never
withany
inField
(your second example) orFieldExtended
(your last example) it would all still be type safe.So is it a form of convention to use
never
as the last not handled condition to be on the safe side?FieldExtended
is basically the identity function with type checks. I can understand that a code editor might use such a function. But as an app developer, what would be a use-case for me to actually use something likeFieldExtended
?