Repository navigation
JSDOC @type tag crashes with simple export #36830
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
TypeScript Version: 3.9.0-dev.20200215 (also tested 3.7.5)
(the last one that doesn't crash is v3.7.1-rc. v3.7.2 crashes)
Search Terms:
Maximum call stack size exceeded
getTypeOfFuncClassEnumModule
Code
/lib/index.js:
/** @type {import('../types/index').xxx} */
function xxx() {
return null;
}/types/index.d.ts:
export function xxx(): string;/tsconfig.json:
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"esModuleInterop": true,
"lib": [
"dom",
"esnext"
],
"allowJs": true,
"checkJs": true,
"noEmit": true,
"resolveJsonModule": true,
"strict": true,
"moduleResolution": "node",
"baseUrl": ".",
}
}Expected behavior:
No crash.
Typescript error about function returning wrong error type.
Actual behavior:
Crash.
/me/ts-crash-test/node_modules/typescript/lib/tsc.js:81193
throw e;
^
RangeError: Maximum call stack size exceeded
at getSymbolLinks (/me/ts-crash-test/node_modules/typescript/lib/tsc.js:28829:32)
at getTypeOfFuncClassEnumModule (/me/ts-crash-test/node_modules/typescript/lib/tsc.js:33936:25)
at getTypeOfSymbol (/me/ts-crash-test/node_modules/typescript/lib/tsc.js:34045:24)
at getTypeFromJSDocValueReference (/me/ts-crash-test/node_modules/typescript/lib/tsc.js:36634:33)
at getTypeReferenceType (/me/ts-crash-test/node_modules/typescript/lib/tsc.js:36620:33)
at getTypeFromJSDocValueReference (/me/ts-crash-test/node_modules/typescript/lib/tsc.js:36648:36)
at getTypeReferenceType (/me/ts-crash-test/node_modules/typescript/lib/tsc.js:36620:33)
at getTypeFromJSDocValueReference (/me/ts-crash-test/node_modules/typescript/lib/tsc.js:36648:36)
at getTypeReferenceType (/me/ts-crash-test/node_modules/typescript/lib/tsc.js:36620:33)
at getTypeFromJSDocValueReference (/me/ts-crash-test/node_modules/typescript/lib/tsc.js:36648:36)
Playground Link:
https://github.com/rchl/ts-crash-test
Related Issues:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Activity
orta commentedon Apr 1, 2020
Cool, reproduced with:
In normal TypeScript code, you wouldn't write
import('../folder/index').zzz- but would writetypeof import('../folder/index').zzzto get to the type() => string- doing this doesn't cause the loop in the code.Which I think leads to another question, what should be the behavior here in JSDoc world? Do we assume we want the
typeofto be assumed because you're using@typeor does it still represent the export-ed identifier ofzzz?orta commentedon Apr 1, 2020
Asked around, and the opinion is yes - we want to pretend there's a
typeofbefore the import in this case - gonna pair on it next weekOnly do an extra JSDoc type reference lookup when on a class - fixes m…
Only do an extra JSDoc type reference lookup when on a class - fixes m…
Only do an extra JSDoc type reference lookup when on a class - fixes m…
fix(ts): Add typeof' in @type of assert
orta commentedon Aug 18, 2020
A fix for this got merged yesterday: #39770