Skip to content

Generic using typeof may cause Maximum call stack size exceeded #17231

Closed
@NStal

Description

@NStal

TypeScript Version: 2.4.1

Code

class ServiceBase<T>{
    field: T
}
class Service extends ServiceBase<typeof Service.Base>{
}
namespace Service {
    export const Base = {
        name: "1",
        value: 5
    }
}

Expected behavior: Compiles

Actual behavior:

/usr/lib/node_modules/typescript/lib/tsc.js:55776
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at getResolvedSymbol (/usr/lib/node_modules/typescript/lib/tsc.js:30411:35)
    at checkIdentifier (/usr/lib/node_modules/typescript/lib/tsc.js:31493:26)
    at checkExpressionWorker (/usr/lib/node_modules/typescript/lib/tsc.js:35550:28)
    at checkExpression (/usr/lib/node_modules/typescript/lib/tsc.js:35534:42)
    at checkNonNullExpression (/usr/lib/node_modules/typescript/lib/tsc.js:33160:37)
    at checkPropertyAccessExpressionOrQualifiedName (/usr/lib/node_modules/typescript/lib/tsc.js:33181:24)
    at checkQualifiedName (/usr/lib/node_modules/typescript/lib/tsc.js:33178:20)
    at checkExpression (/usr/lib/node_modules/typescript/lib/tsc.js:35531:24)
    at getTypeFromTypeQueryNode (/usr/lib/node_modules/typescript/lib/tsc.js:27378:53)
    at getTypeFromTypeNode (/usr/lib/node_modules/typescript/lib/tsc.js:28161:28)

If I move Base elsewhere or rename the namespace Service, everything goes fine. So I guess it must be a
compiler bug.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions