farrow-js / farrow

A Type-Friendly Web Framework for Node.js
https://www.farrowjs.com
MIT License
768 stars 37 forks source link

Feature Request(farrow-schema): Need a Bottom Type like never #162

Closed tqma113 closed 2 years ago

tqma113 commented 2 years ago

As the title. Should we create a new Schema to express never? Or I missed it?

Lucifier129 commented 2 years ago

What are the usages of never for schema?

tqma113 commented 2 years ago
const S = Struct({
  foo: Never
})

Indicates that the foo field should not exist?

Lucifier129 commented 2 years ago
const S = Struct({
  foo: Never
})

object/struct is product type, means and0 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.

tqma113 commented 2 years ago

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:

Lucifier129 commented 2 years ago

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.