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

Simplify precondition generics. #13

Open
metasansana opened this issue May 7, 2022 · 1 comment
Open

Simplify precondition generics. #13

metasansana opened this issue May 7, 2022 · 1 comment

Comments

@metasansana
Copy link
Contributor

Currently usage of this module requires a lot of type assertions and type parameter passing, it makes for some unsightly situations often hidden behind .

@metasansana
Copy link
Contributor Author

Coming back to the record types, there probably isn't any need to track the field level types. The idea behind this module is that once a value passes the checks then we consider it to be valid for the destination type. Whether the checks are sufficient enough is left in the hands of the user. That of course makes the process inherently type unsafe but that in most cases might be an allowable tradeoff for ease of use.

Restrict for example might look like this:

const restrict = <A, B extends object>(value:A) => B

where isRecord should be incorporated because restrict only works on objects.

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

1 participant