Skip to content

Auto-import failure: Cannot read property 'length' of undefined #37833

@amcasey

Description

@amcasey

tsconfig.json

{
    "compilerOptions": {
        "allowJs": true,
        "checkJs": true,
        "noEmit": true,
    }
}

test.js

class Abcde {
    x
}

module.exports = {
    Abcde
};

index.ts

export var foo = 1
declare module "./test" {
    interface Abcde { b: string }
}

Abcde// Invoke completion here to trigger auto-import

Expected: Abcde is imported from test.
Actual:

Exception has occurred: TypeError
TypeError: Cannot read property 'length' of undefined
    at getLocalTypeParametersOfClassOrInterfaceOrTypeAlias (e:\ts_gh\src\compiler\checker.ts:8292:32)
    at typeParametersToTypeParameterDeclarations (e:\ts_gh\src\compiler\checker.ts:5002:62)
    at e:\ts_gh\src\compiler\checker.ts:4098:82
    at withContext (e:\ts_gh\src\compiler\checker.ts:4130:39)
    at Object.symbolToTypeParameterDeclarations (e:\ts_gh\src\compiler\checker.ts:4098:21)
    at e:\ts_gh\src\services\symbolDisplay.ts:634:44
    at Object.mapToDisplayParts (e:\ts_gh\src\services\utilities.ts:2091:13)
    at writeTypeParametersOfSymbol (e:\ts_gh\src\services\symbolDisplay.ts:633:40)
    at Object.getSymbolDisplayPartsDocumentationAndSymbolKind (e:\ts_gh\src\services\symbolDisplay.ts:289:13)
    at E:\ts_gh\built\local\tsserver.js:111800:41
    at Object.runWithCancellationToken (e:\ts_gh\src\compiler\checker.ts:662:28)
    at createCompletionDetailsForSymbol (e:\ts_gh\src\services\completions.ts:678:15)
    at Object.getCompletionEntryDetails (e:\ts_gh\src\services\completions.ts:659:24)
    at Proxy.getCompletionEntryDetails (e:\ts_gh\src\services\services.ts:1476:32)
    at e:\ts_gh\src\server\session.ts:1683:53
    at Object.mapDefined (e:\ts_gh\src\compiler\core.ts:475:32)
    at IOSession.Session.getCompletionEntryDetails (e:\ts_gh\src\server\session.ts:1681:28)
    at Session.handlers.ts.createMapFromTemplate._a.<computed> (e:\ts_gh\src\server\session.ts:2455:51)
    at e:\ts_gh\src\server\session.ts:2665:69
    at IOSession.Session.executeWithRequestId (e:\ts_gh\src\server\session.ts:2655:25)
    at IOSession.Session.executeCommand (e:\ts_gh\src\server\session.ts:2665:29)
    at IOSession.Session.onMessage (e:\ts_gh\src\server\session.ts:2694:23)
    at Interface.<anonymous> (e:\ts_gh\src\tsserver\server.ts:577:22)
    at Interface.emit (events.js:203:13)
    at Interface._onLine (readline.js:316:10)
    at Interface._normalWrite (readline.js:461:12)
    at Socket.ondata (readline.js:172:10)
    at Socket.emit (events.js:203:13)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:276:11)
    at Socket.Readable.push (_stream_readable.js:210:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)

TS version: c47aca0

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions