Skip to content

JS: Maximum call stack size exceeded at getTypeFromJSDocValueReference in 3.7.2 #34926

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
brendankenny opened this issue Nov 5, 2019 · 6 comments · Fixed by #35057
Closed
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue

Comments

@brendankenny
Copy link
Contributor

TypeScript Version: 3.7.2, 3.8.0-dev.20191105

Search Terms:
JSDoc Type reference Maximum call stack size exceeded getTypeFromJSDocValueReference

Code
Unfortunately I don't have a small case test case yet. The easiest steps I have so far:

  • git clone https://github.com/GoogleChrome/lighthouse.git
  • cd lighthouse
  • yarn
  • yarn add -D [email protected]
  • yarn tsc

Expected behavior:
Complete tsc run

Actual behavior:

~/lighthouse/node_modules/typescript/lib/tsc.js:78629
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at getTypeFromJSDocValueReference (~/lighthouse/node_modules/typescript/lib/tsc.js:35334:48)
    at getTypeReferenceType (~/lighthouse/node_modules/typescript/lib/tsc.js:35323:33)
    at getTypeFromJSDocValueReference (~/lighthouse/node_modules/typescript/lib/tsc.js:35348:32)
    at getTypeReferenceType (~/lighthouse/node_modules/typescript/lib/tsc.js:35323:33)
    at getTypeFromJSDocValueReference (~/lighthouse/node_modules/typescript/lib/tsc.js:35348:32)
    at getTypeReferenceType (~/lighthouse/node_modules/typescript/lib/tsc.js:35323:33)
    at getTypeFromJSDocValueReference (~/lighthouse/node_modules/typescript/lib/tsc.js:35348:32)
    at getTypeReferenceType (~/lighthouse/node_modules/typescript/lib/tsc.js:35323:33)
    at getTypeFromJSDocValueReference (~/lighthouse/node_modules/typescript/lib/tsc.js:35348:32)
    at getTypeReferenceType (~/lighthouse/node_modules/typescript/lib/tsc.js:35323:33)
error Command failed with exit code 1.

In 3.7.1-rc there were many of the Property 'methodName' does not exist on type 'typeof ClassName' errors that were being worked on in #34671, but it looks like the fix(es) struggles with something in our dependency graph and/or styles of declarations.

No issues or compilation errors using [email protected] (though we're fine if there are new errors exposed by 3.7 that will need to be fixed in our code :)

Related Issues:
This seems very related to the cluster of issues @sandersn was working on in #34671, #34707, #34685, and #34802

@ksmithut
Copy link

ksmithut commented Nov 6, 2019

I was able to reproduce with this code:

/**
 * @param {import('aws-sdk')} aws
 */
function test (aws) {}

Something in the typings in aws-sdk (and others I assume) is causing this

@voxpelli
Copy link

voxpelli commented Nov 7, 2019

Experiencing similar, with slightly different callstack:

RangeError: Maximum call stack size exceeded
    at getSymbolLinks (/my-project/node_modules/typescript/lib/tsc.js:27740:32)
    at getTypeOfFuncClassEnumModule (/my-project/node_modules/typescript/lib/tsc.js:32593:25)
    at getTypeOfSymbol (/my-project/node_modules/typescript/lib/tsc.js:32702:24)
    at getTypeFromJSDocValueReference (/my-project/node_modules/typescript/lib/tsc.js:35295:29)
    at getTypeReferenceType (/my-project/node_modules/typescript/lib/tsc.js:35283:33)
    at getTypeFromJSDocValueReference (/my-project/node_modules/typescript/lib/tsc.js:35309:32)
    at getTypeReferenceType (/my-project/node_modules/typescript/lib/tsc.js:35283:33)
    at getTypeFromJSDocValueReference (/my-project/node_modules/typescript/lib/tsc.js:35309:32)
    at getTypeReferenceType (/my-project/node_modules/typescript/lib/tsc.js:35283:33)
    at getTypeFromJSDocValueReference (/my-project/node_modules/typescript/lib/tsc.js:35309:32)

@voxpelli
Copy link

voxpelli commented Nov 7, 2019

Digging into the code, it seems to be related to the change made in #34683

More specifically the node.kind === SyntaxKind.ImportType check in 8223c07, which seems to in some cases make getTypeReferenceType() and getTypeFromJSDocValueReference() call each other in at least a near circular way.

@sandersn
Copy link
Member

sandersn commented Nov 7, 2019

@RyanCavanaugh let's take this one for 3.7.3 too. Sounds like it breaks lighthouse and aws-sdk.

@sandersn sandersn self-assigned this Nov 7, 2019
@sandersn sandersn added Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output labels Nov 7, 2019
@sandersn sandersn added this to the TypeScript 3.7.3 milestone Nov 7, 2019
@sandersn
Copy link
Member

sandersn commented Nov 7, 2019

Here's a self-contained repro:

/** @param {import('./ex')} a */
function test(a) { }
export var crash: {};

Notably, this does not crash:

declare var nocrash: {}
export = nocrash;

@sandersn
Copy link
Member

My previous fix for import types was too eager. The jsdoc-value-as-type fallback is only needed for import types followed by qualified names.

@sandersn sandersn added the Fix Available A PR has been opened for this issue label Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants