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

Call stack error when generating documentation for types with self-recursive type arguments #1330

Closed
ackwell opened this issue Jul 1, 2020 · 3 comments
Labels
bug Functionality does not match expectation

Comments

@ackwell
Copy link

ackwell commented Jul 1, 2020

Search terms

Maximum call stack size exceeded, recursive type, recursive default type parameter

Expected Behavior

Typedoc generates output without error

Actual Behavior

Typedoc throws RangeError: Maximum call stack size exceeded

Stack trace (while most of this is in lodash, the loop seems to be occuring around Converter.convertTypes.

RangeError: Maximum call stack size exceeded
    at isArrayLike (PROJDIR/node_modules/lodash/lodash.js:11333:58)
    at isArrayLikeObject (PROJDIR/node_modules/lodash/lodash.js:11362:37)
    at PROJDIR/node_modules/lodash/lodash.js:8471:13
    at arrayFilter (PROJDIR/node_modules/lodash/lodash.js:582:11)
    at Function.unzip (PROJDIR/node_modules/lodash/lodash.js:8470:15)
    at apply (PROJDIR/node_modules/lodash/lodash.js:474:27)
    at Function.zip (PROJDIR/node_modules/lodash/lodash.js:6563:16)
    at Converter.convertTypes (PROJDIR/node_modules/typedoc/dist/lib/converter/converter.js:140:11)
    at ReferenceConverter.convertType (PROJDIR/node_modules/typedoc/dist/lib/converter/types/reference.js:48:47)
    at Converter.convertType (PROJDIR/node_modules/typedoc/dist/lib/converter/converter.js:133:38)

Steps to reproduce the bug

Minimal reproduction gist. To reproduce, install packages (I'm using yarn), and run typedoc with no arguments.

It looks like the root of this issue is the two-step recursive default for the Example default type argument (Example<ExampleParam> -> Example<Example>). Removing the type alias causes TS itself to error - leaving it in causes this loop in typedoc alone.

(The above is updated, original reproduction made use of @types/color, where I first encountered this issue. It, likewise, has the same construct shown in this reproduction.)

Environment

  • Typedoc version: 0.17.8
  • TypeScript version: 3.9.5
  • Node.js version: 12.18.0
  • OS: OSX 10.15.5
@ackwell ackwell added the bug Functionality does not match expectation label Jul 1, 2020
@ackwell ackwell changed the title Call stack error when generating documentation for recursive types Call stack error when generating documentation for types with self-recursive type arguments Jul 1, 2020
@Gerrit0 Gerrit0 closed this as completed in 7fc721c Jul 4, 2020
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 4, 2020

Recursive types are a pain. Fixed in 7fc721c. I should be able to put a release together tomorrow. Thanks for the reproduction! It was really helpful in narrowing down the issue quickly.

@sylvanaar
Copy link

Hi, this issue is marked as closed - but the code has never been released. I just started with TypeDoc and for whatever reason - it has this crash when I try to run it.

I was able to pull master and build lastest. But you really should release this fix - it is a bad sign for the health of this project.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Aug 9, 2020

"bad sign for the health of the project" - I work on TypeDoc when I have time on the weekends. Aside from occasional PRs from others, that's all it has... and is more than it had for quite a while. I think TypeDoc will be around for a while. If you need a project which is more enterprise grade, I recommend taking a look at api-extractor.

The fix is now released in 0.18.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

3 participants