Typedoc: Call stack error when generating documentation for types with self-recursive type arguments

Created on 1 Jul 2020  路  3Comments  路  Source: TypeStrong/typedoc

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
bug

Most helpful comment

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

All 3 comments

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

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.

"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.

Was this page helpful?
0 / 5 - 0 ratings