Skip to content

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

Closed
@ackwell

Description

@ackwell

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions