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

Maximum call stack size exceeded #2

Closed
arvind opened this issue Jun 11, 2017 · 5 comments · Fixed by #145
Closed

Maximum call stack size exceeded #2

arvind opened this issue Jun 11, 2017 · 5 comments · Fixed by #145
Labels

Comments

@arvind
Copy link
Member

arvind commented Jun 11, 2017

When I try to run typescript-to-json-schema against the Legend union type defined here, I get a Maximum call stack size exceeded error. Each individual type within the union builds just fine, however.

Is there something about my type definitions I should be modifying/simplifying, or is this a bug with typescript-to-json-schema?

$ ./node_modules/.bin/typescript-to-json-schema --path typings/legend.ts --type Legend
/Users/arvind/Research/vega3/vega-parser/node_modules/typescript-to-json-schema/dist/typescript-to-json-schema.js:32
        throw error;
        ^

RangeError: Maximum call stack size exceeded
    at CircularReferenceTypeFormatter.getChildren (/Users/arvind/Research/vega3/vega-parser/node_modules/typescript-to-json-schema/dist/src/CircularReferenceTypeFormatter.js:26:23)
...
$ ./node_modules/.bin/typescript-to-json-schema --path typings/legend.ts --type SizeLegend
(executes correctly)
@arvind
Copy link
Member Author

arvind commented Jun 11, 2017

Interestingly, if I switch the interfaces to type aliases, I've found:

  • The same error if each individual legend is an intersection with base legend:
    export type SizeLegend = BaseLegend & {size: string};
    ...
    export type Legend = SizeLegend | ShapeLegend | ...
  • However, no error if the intersection occurs on Legend:
    export type SizeLegend = {size: string};
    ...
    export type Legend = BaseLegend & (SizeLegend | ShapeLegend | ...);

While the latter is also correct, the former (or the interface formulation currently checked in) provides more useful exported types.

@arvind arvind added bug and removed discussion labels Jun 11, 2017
@domoritz
Copy link
Member

As with #4, I suspect this is because of the version on NPM. I don't get this error.

@domoritz
Copy link
Member

Seeing the same issue when I use the full typings.

@domoritz domoritz reopened this Jun 11, 2017
@domoritz
Copy link
Member

The problem seems to be that we actually need a larger stack.

node --stack-size=100000 dist/typescript-to-json-schema.js --path /Users/domoritz/Developer/UW/vega-parser/typings/legend.ts --type Legend

Works fine.

@domoritz
Copy link
Member

After looking at this in more depth, I can't think of a fix that does not involve some non-trivial rewrite of the formatting logic. Please increase the stack size.

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

Successfully merging a pull request may close this issue.

2 participants