Skip to content

getReturnType stack overflow when using recursive generic function with accumulated type argumentΒ #63759

Description

πŸ”Ž Search Terms

"getReturnType", "stack overflow", "Maximum call stack size exceeded", "recursive generic function"

πŸ•— Version & Regression Information

This is happening in v6 and tsgo (I didn't check prior versions)

⏯ Playground Link

No response

πŸ’» Code

Coming from typescript-eslint/typescript-eslint#12705, I created a repro that's agnostic to ESLint:

// A generic function type whose call signature returns the same type,
// instantiated with an accumulated type argument.
type Recursive<T> = <U>() => Recursive<T & U>;

export declare const subject: Recursive<unknown>;

https://github.com/StyleShit/repros/tree/main/ts-getReturnType-stack-overflow

πŸ™ Actual behavior

Walking the function's signature and return type is failing with "Maximum call stack size exceeded" error

πŸ™‚ Expected behavior

Walking should not fail

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions