Skip to content

Maximum call stack size exceeded for complex type #2507

@jgke

Description

@jgke

Search terms

Hi! I have a complex type generated with ts-proto, which is causing typedoc to crash with infinite recursion somewhere inside tsc.

Expected Behavior

Not crash.

Actual Behavior

$ npx typedoc
TypeDoc exiting with unexpected error:
RangeError: Maximum call stack size exceeded
    at typeToTypeNodeWorker (/path/to/project/node_modules/typescript/lib/typescript.js:49973:36)
    at typeToTypeNodeHelper (/path/to/project/node_modules/typescript/lib/typescript.js:49969:26)
    at typeToTypeNodeWorker (/path/to/project/node_modules/typescript/lib/typescript.js:50215:34)
    at typeToTypeNodeHelper (/path/to/project/node_modules/typescript/lib/typescript.js:49969:26)
[... repeating ...]

Steps to reproduce the bug

I tried to make this as minimal as possible. There's probably still something I managed to miss, but at least it's better than the original 540-line file.

export interface Struct {
    fields: { [key: string]: Value };
}

export interface Struct_FieldsEntry {
    value: Value | undefined;
}

export interface Value {
    structValue?: Struct | undefined;
    listValue?: ListValue | undefined;
}

export interface ListValue {
    values: Value[];
}

export function fromPartial<I extends Exact<DeepPartial<Struct_FieldsEntry>, I>>(object: I): Struct_FieldsEntry {
    return undefined as any;
};

type Builtin = undefined;

export type DeepPartial<T> = T extends Builtin ? T : Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
    ? P
    : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

Also available at TypeStrong/typedoc-repros#39

Environment

  • Typedoc version: 0.25.8
  • TypeScript version: 5.3.3
  • Node.js version: v18.17.0
  • OS: Ubuntu

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