Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NStal opened this issue Jul 16, 2017 · 0 comments
Closed

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

NStal opened this issue Jul 16, 2017 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@NStal
Copy link

NStal commented Jul 16, 2017

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.

@NStal NStal changed the title Maximum call stack size exceeded Generic using typeof may cause Maximum call stack size exceeded Jul 16, 2017
@mhegazy mhegazy added the Bug A bug in TypeScript label Aug 17, 2017
@mhegazy mhegazy added this to the TypeScript 2.6 milestone Aug 17, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Aug 19, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants