Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tqma113 opened this issue Feb 25, 2022 · 5 comments
Closed

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

tqma113 opened this issue Feb 25, 2022 · 5 comments

Comments

@tqma113
Copy link
Collaborator

tqma113 commented Feb 25, 2022

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

@Lucifier129
Copy link
Collaborator

What are the usages of never for schema?

@tqma113
Copy link
Collaborator Author

tqma113 commented Feb 26, 2022

const S = Struct({
  foo: Never
})

Indicates that the foo field should not exist?

@Lucifier129
Copy link
Collaborator

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
Copy link
Collaborator Author

tqma113 commented Feb 26, 2022

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:

  • there is already a partial, but no required
  • there is already a Nullable, but no any helper to remove Null and Undefined from a schema
  • there is no way to get schema of field ObjectType/Struct
  • Distributive Conditional Types
    • get item schema of List(S)
    • get value schema of Record
    • get item schema of Tuple
    • ...

@Lucifier129
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants