-
Notifications
You must be signed in to change notification settings - Fork 328
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
tag recursion #80
Comments
That's a great idea
What do you need in order to implement recursion? In the type ICategory = {
name: string
categories: Array<ICategory>
}
const Category = t.recursion('Category', self =>
t.interface({
name: t.string,
categories: t.array(self)
})
)
console.log(Category._tag) // RecursiveType
console.log(Category.name) // Category
console.log((Category.type as any)._tag) // InterfaceType
const type = Category.type as t.InterfaceType<any>
console.log(type.props.categories.type) // RecursiveType { name: 'Category', ... } You can try it out with |
I've done a quick check (pun intended), |
I'm currently writing a lib to generate Generators for 'testcheck' (https://github.com/leebyron/testcheck-js) library (btw any constructive criticism on that choice is welcome)
I've covered so far:
interface, string, number, boolean, literal, union, intersection (of recursive unions/intersections of interfaces/partials), array, partial
I can't implement recursion because io-ts currently does not provide a tag on it.
Can it be done?
Thanks!
The text was updated successfully, but these errors were encountered: