-
Notifications
You must be signed in to change notification settings - Fork 33
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
Recursive types #23
Comments
Do you get that error at runtime or at compile time? I would guess if the error happens at compile time it's probably an issue with typescript-json-schema, which is one of our dependencies. An actual small example that fails would be really helpful for debugging this. If it happens at runtime, I wonder if your data structure is actually recursive in the sense of referencing itself, which is not the same as a recursive type. i.e. the following should be fine interface Leaf {
value: string;
}
interface Branch {
left: Leaf | Branch;
right: Leaf | Branch;
} {"left": {"value": "hello"}, "right": {"left": {"value": "beautiful"}, "right": {"value": "world"}}} but not if you pass it: const tree = {left: {value: 'hello'}};
tree.right = tree;
validate(tree); |
it is at compile time. Here's an example:
npx typescript-json-validator Example.ts Form In my case I have a schema that has questions, which can have options. Each option can have more questions inside if that option is selected. Edit: looks like its been mentioned before in that repo: YousefED/typescript-json-schema#33 |
Just checking in to say this issue still occurs, here is a stack trace:
and the offending type:
|
Any plans or ideas on how to get this to work with recursive types? I get an error when attempting to use it,
Maximum call stack size exceeded
I guess for now the alternative is to flatten my data for validation purposesThe text was updated successfully, but these errors were encountered: