Skip to content

JSDOC @type tag crashes with simple export #36830

Closed
@rchl

Description

@rchl

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:

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions