Skip to content

Recursive default generic causes Maximum call stack size exceeded #15926

Closed
@fathyb

Description

@fathyb

TypeScript Version: 2.3.2

Code

type PrimitiveValue<T = PrimitiveValue> = null|string|boolean|number|T[]

Expected behavior:
Show an error that says recursive generics are not permitted

Actual behavior:

RangeError: Maximum call stack size exceeded
    at resolveEntityName (node_modules/typescript/lib/tsc.js:21829:35)
    at getTypeFromTypeReference (node_modules/typescript/lib/tsc.js:26048:54)
    at getTypeFromTypeNode (node_modules/typescript/lib/tsc.js:26832:28)
    at getDefaultFromTypeParameter (node_modules/typescript/lib/tsc.js:25286:66)
    at getMinTypeArgumentCount (node_modules/typescript/lib/tsc.js:25538:26)
    at getTypeFromTypeAliasReference (node_modules/typescript/lib/tsc.js:25939:44)
    at getTypeFromTypeReference (node_modules/typescript/lib/tsc.js:26051:53)
    at getTypeFromTypeNode (node_modules/typescript/lib/tsc.js:26832:28)
    at getDefaultFromTypeParameter (node_modules/typescript/lib/tsc.js:25286:66)
    at getMinTypeArgumentCount (node_modules/typescript/lib/tsc.js:25538:26)

It seems to cause VS Code language service to crash too, and it gives no information about which line causes the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions