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

Interface and Class with same name leeds to endless loop #2495

Closed
besessener opened this issue Feb 5, 2024 · 2 comments
Closed

Interface and Class with same name leeds to endless loop #2495

besessener opened this issue Feb 5, 2024 · 2 comments
Labels
bug Functionality does not match expectation

Comments

@besessener
Copy link

besessener commented Feb 5, 2024

Search terms

  • RangeError: Maximum call stack size exceeded
  • interface and claas that implements it ith same name

Expected Behavior

no crash

Actual Behavior

TypeDoc exiting with unexpected error:
RangeError: Maximum call stack size exceeded
    at ProjectReflection.getReflectionById (C:\Repos\Claas\cde-fe-app\node_modules\typedoc\dist\lib\models\reflections\project.js:193:22)
    at get reflection [as reflection] (C:\Repos\Claas\cde-fe-app\node_modules\typedoc\dist\lib\models\types.js:678:35)
    at C:\Repos\Claas\cde-fe-app\node_modules\typedoc\dist\lib\output\themes\default\templates\hierarchy.js:17:30
    at Array.map (<anonymous>)
    at fullHierarchy (C:\Repos\Claas\cde-fe-app\node_modules\typedoc\dist\lib\output\themes\default\templates\hierarchy.js:16:33)
    at C:\Repos\Claas\cde-fe-app\node_modules\typedoc\dist\lib\output\themes\default\templates\hierarchy.js:17:44
    at Array.map (<anonymous>)
    at fullHierarchy (C:\Repos\Claas\cde-fe-app\node_modules\typedoc\dist\lib\output\themes\default\templates\hierarchy.js:16:33)
    at C:\Repos\Claas\cde-fe-app\node_modules\typedoc\dist\lib\output\themes\default\templates\hierarchy.js:17:44
    at Array.map (<anonymous>)

Steps to reproduce the bug

export interface Foo {
  type?: string;
  name?: string;
  id: string;
  hidden?: boolean;
}

export class Foo extends Serializable implements Foo {
  constructor(params: Foo) {
    super(params);
  }
}

The above example might look strange. Like this, the class Foo does not need to implement all the properties of interface Foo. The properties are just there (Mixin).

My assumption is, that this code leads to an endless loop.....or actually endless recursion of function function fullHierarchy(context, root)

Environment

  • Typedoc version: 0.25.7
  • TypeScript version: 5.1.6
  • Node.js version: 21.6.1
  • OS: Windows 11
@besessener besessener added the bug Functionality does not match expectation label Feb 5, 2024
@csvtuda
Copy link

csvtuda commented Feb 5, 2024

Can confirm, I am seeing the same behaviour. MRE:

// index.ts
interface IAnimal {
  name: number;
}

interface IFish extends IAnimal {
  maxDepth: number;
}

class IFish implements IFish {}

Result:

$ npx typedoc index.ts
TypeDoc exiting with unexpected error:
RangeError: Maximum call stack size exceeded
    at fullHierarchy (/home/me/fishProject/node_modules/typedoc/dist/lib/output/themes/default/templates/hierarchy.js:11:21)
    at /home/me/fishProject/node_modules/typedoc/dist/lib/output/themes/default/templates/hierarchy.js:17:44
    at Array.map (<anonymous>)
    at fullHierarchy (/home/me/fishProject/node_modules/typedoc/dist/lib/output/themes/default/templates/hierarchy.js:16:33)
    at /home/me/fishProject/node_modules/typedoc/dist/lib/output/themes/default/templates/hierarchy.js:17:44
    at Array.map (<anonymous>)
    at fullHierarchy (/home/me/fishProject/node_modules/typedoc/dist/lib/output/themes/default/templates/hierarchy.js:16:33)
    at /home/me/fishProject/node_modules/typedoc/dist/lib/output/themes/default/templates/hierarchy.js:17:44
    at Array.map (<anonymous>)
    at fullHierarchy (/home/me/fishProject/node_modules/typedoc/dist/lib/output/themes/default/templates/hierarchy.js:16:33)

Unfortunately, I do not really know the purpose of such structures, but they exist (probably legacy code) and cause the issue mentioned above.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 7, 2024

Huh, I guess that's valid TS... didn't think I had to worry about infinite loops when dealing with inheritance.

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