Maximum call stack size exceeded if there is a prop with type React.ReactNode

This issue has been tracked since 2023-01-19.

Search terms

When I run yarn typedoc which runs npx typedoc src/index.tsx --ignoreCompilerErrors --excludeExternals --json coverage/props.json --pretty this command throws an error

function createExpressionFromSymbolChain(chain, index) {
RangeError: Maximum call stack size exceeded

I have a pretty simple Tooltip component. Code looks like this. Irrelevant to this error but Style.ts file contains styled component and it's being exported and being imported below file.

import React, { useState } from 'react';
import Root from './style';

export interface Props {
  /** ClassName standard property */
  className?: string;
  /** style object */
  style?: any;
  /** id */
  id?: string;
  /** message of Tooltip when hovered */
  text?: string;
  /** React child node */
  children?: React.ReactNode;
}

export default function Tooltip({
  className, style, id, children, text,
}: Props) {
  const [showTooltip, setShowTooltip] = useState(false);

  return (
    <Root
      id={id}
      style={style}
      className={className}
      onMouseEnter={() => setShowTooltip(true)}
      onMouseLeave={() => setShowTooltip(false)}
    >
      {children}
      {showTooltip && <div className="tooltip">{text}</div>}
    </Root>
  );
}

Expected Behavior

I expect to run the command below without an error.
npx typedoc src/index.tsx --ignoreCompilerErrors --excludeExternals --json coverage/props.json --pretty

Actual Behavior

it throws the following error:

function createExpressionFromSymbolChain(chain, index) {
RangeError: Maximum call stack size exceeded

It works as expected when I change React.ReactNode to React.ReactChildren. Problem is on React.ReactNode

Steps to reproduce the bug

Just create a prop within Props interface as type React.ReactNode and run typedoc command

tsconfig.json

{
  "compilerOptions": {
    "lib": [
      "ESNext",
      "DOM"
    ],
    "target": "es2018",
    "module": "es6",
    "noEmitOnError": true,
    "jsx": "react",
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": true,
    "strict": true,
    "allowJs": false,
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "baseUrl": ".",
    "outDir": "lib",
    "plugins": [
      {
        "name": "typescript-styled-plugin",
        "tags": [
          "styled",
          "css",
          "sty"
        ]
      }
    ]
  },
  "files": [
    "src/index.tsx",
    "utils/svg.d.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}
  "dependencies": {
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "react-scripts": "4.0.3",
    "styled-components": "5.3.6",
    "typedoc": "0.23.24",
    "typescript": "4.9.4"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^4.5.0",
    "@typescript-eslint/parser": "^4.5.0",
    "eslint-config-airbnb-typescript": "^12.0.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-react": "^7.21.5",
    "eslint-plugin-react-hooks": "^4.2.0",
    "jest": "^26.6.0",
    "jest-styled-components": "^7.0.3",
    "react-test-renderer": "^17.0.1",
    "typescript-styled-plugin": "^0.15.0"
  },

Environment

  • Typedoc version: latest
  • TypeScript version: 4.6.4
  • Node.js version: 18.9.0
  • OS: macos
Gerrit0 wrote this answer on 2023-02-04

--ignoreCompilerErrors

Bug reports with this option turned on are out of scope. Your code must compile without errors for the TS api to work consistently.

From the bug report issue template:

Note: Turn off skipErrorChecks before reporting a crash. Bug reports for crashes with that option
on are out of scope.

More Details About Repo
Owner Name TypeStrong
Repo Name typedoc
Full Name TypeStrong/typedoc
Language TypeScript
Created Date 2014-05-24
Updated Date 2023-03-19
Star Count 6487
Watcher Count 68
Fork Count 639
Issue Count 48

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date