Closed tqma113 closed 2 years ago
What are the usages of never for schema?
const S = Struct({
foo: Never
})
Indicates that the foo
field should not exist?
const S = Struct({
foo: Never
})
object/struct
is product type
, means and
,0 x a = 0
,any Never
will make all type become no value, zero inhabitants.
In union case, it is sum type
, means or
, 0 + a = a
. never
is the identity element
of the monoid of union
, has no effect.
number | never
is equal to number
.
So it's hard to find a reason to add Never
, we can delay the decision until we figure out the usage.
Got it, I finished sorting out the farrow-schem API documentation. And then found that, when compared to TypeScript's type system, the farrow-schema
is missing some things, such as the Never mentioned above (which, of course, the current conclusion is that there is no need to add it) and other:
partial
, but no required
Nullable
, but no any helper to remove Null
and Undefined
from a schemaList(S)
Record
Tuple
We don't need to implement the full spectrum of TypeScript
's type system right now.
The feedback that came from the users/developers of farrow-scehma
will lead us to reach the target position one by one.
As the title. Should we create a new Schema to express never? Or I missed it?