Skip to content

"Maximum call stack size exceeded" with recursive type parameter default #17049

Closed
@WasabiFan

Description

@WasabiFan

TypeScript Version: 2.3.4, 2.4.1

Code

class TestClass<T = TestClass> {

}

Expected behavior:

The code compiles such that I could reference the type in any of the following ways:

TestClass
TestClass<TestClass>
TestClass<MyOtherTestClassImplementation>

Actual behavior (v2.3.4):

C:\Users\user\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:53887
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at Map.get (native)
    at getSymbol (C:\Users\user\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:21268:38)
    at resolveName (C:\Users\user\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:21453:38)
    at resolveEntityName (C:\Users\user\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:21881:26)
    at getTypeFromTypeReference (C:\Users\user\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:26096:54)
    at getTypeFromTypeNode (C:\Users\user\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:26880:28)
    at getDefaultFromTypeParameter (C:\Users\user\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:25333:66)
    at getMinTypeArgumentCount (C:\Users\user\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:25585:26)
    at getTypeFromClassOrInterfaceReference (C:\Users\user\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:25955:44)
    at getTypeFromTypeReference (C:\Users\user\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:26098:52)

Presumably this was introduced in #13487.

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