Skip to content

Language service crashes when requesting type of mixin class from JS #26370

@sandersn

Description

@sandersn
// @ts-check
/**
 * @template {new (...args: any[]) => any} T
 * @param {T} S
 */
function mix(S) {
    return class extends S {
        f() { return 0; }
    }
};

class Base {}
const Mixed/**/ = mix(Base);

Request the type of Mixed from the language service.

Expected behavior:

const Mixed: {
   new (...args: any[]): mix<typeof Base>.(Anonymous class);
  prototype: max<any>.(Anonymous class);
} & typeof Base

(Just like Typescript)

Actual behavior:

Crash:

Error processing request. Cannot read property 'flags' of undefined
TypeError: Cannot read property 'flags' of undefined
    at lookupSymbolChain (/home/nathansa/ts/built/local/tsserver.js:32817:46)
    at symbolToTypeNode (/home/nathansa/ts/built/local/tsserver.js:32930:29)
    at typeReferenceToTypeNode (/home/nathansa/ts/built/local/tsserver.js:32502:47)
    at typeToTypeNodeHelper (/home/nathansa/ts/built/local/tsserver.js:32265:28)
    at signatureToSignatureDeclarationHelper (/home/nathansa/ts/built/local/tsserver.js:32738:52)
    at createTypeNodesFromResolvedType (/home/nathansa/ts/built/local/tsserver.js:32571:43)
    at createTypeNodeFromObjectType (/home/nathansa/ts/built/local/tsserver.js:32441:35)
    at createAnonymousTypeNode (/home/nathansa/ts/built/local/tsserver.js:32394:42)
    at typeToTypeNodeHelper (/home/nathansa/ts/built/local/tsserver.js:32310:28)
    at mapToTypeNodes (/home/nathansa/ts/built/local/tsserver.js:32688:40)
    at typeToTypeNodeHelper (/home/nathansa/ts/built/local/tsserver.js:32295:37)
    at /home/nathansa/ts/built/local/tsserver.js:32117:106
    at withContext (/home/nathansa/ts/built/local/tsserver.js:32152:37)
    at Object.typeToTypeNode (/home/nathansa/ts/built/local/tsserver.js:32117:28)
    at typeToString (/home/nathansa/ts/built/local/tsserver.js:32096:40)
    at Object.writeType (/home/nathansa/ts/built/local/tsserver.js:29503:24)
    at /home/nathansa/ts/built/local/tsserver.js:90305:25
    at mapToDisplayParts (/home/nathansa/ts/built/local/tsserver.js:90294:13)
    at Object.typeToDisplayParts (/home/nathansa/ts/built/local/tsserver.js:90304:16)
    at Object.getSymbolDisplayPartsDocumentationAndSymbolKind (/home/nathansa/ts/built/local/tsserver.js:100495:62)
    at /home/nathansa/ts/built/local/tsserver.js:112087:41
    at Object.runWithCancellationToken (/home/nathansa/ts/built/local/tsserver.js:29663:28)
    at Object.getQuickInfoAtPosition (/home/nathansa/ts/built/local/tsserver.js:112086:34)
    at IOSession.Session.getQuickInfoWorker (/home/nathansa/ts/built/local/tsserver.js:119609:62)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/home/nathansa/ts/built/local/tsserver.js:118730:61)
    at /home/nathansa/ts/built/local/tsserver.js:120183:88
    at IOSession.Session.executeWithRequestId (/home/nathansa/ts/built/local/tsserver.js:120174:28)
    at IOSession.Session.executeCommand (/home/nathansa/ts/built/local/tsserver.js:120183:33)
    at IOSession.Session.onMessage (/home/nathansa/ts/built/local/tsserver.js:120203:35)
    at Interface.<anonymous> (/home/nathansa/ts/built/local/tsserver.js:121457:27)
    at emitOne (events.js:125:13)
    at Interface.emit (events.js:221:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._normalWrite (readline.js:435:12)
    at Socket.ondata (readline.js:146:10)
    at emitOne (events.js:125:13)
    at Socket.emit (events.js:221:7)
    at addChunk (_stream_readable.js:265:12)
    at readableAddChunk (_stream_readable.js:252:11)
    at Socket.Readable.push (_stream_readable.js:209:10)
    at Pipe.onread (net.js:598:20)

Probably related? #26286

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