Skip to content
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

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

Closed
sandersn opened this issue Aug 10, 2018 · 2 comments
Closed

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

sandersn opened this issue Aug 10, 2018 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output

Comments

@sandersn
Copy link
Member

// @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

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Aug 13, 2018
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.1 milestone Aug 13, 2018
@sandersn
Copy link
Member Author

Very likely to be a duplicate of, or at least related to, #26883 since it's a generic function that returns a class.

@DanielRosenwasser DanielRosenwasser added the Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output label Oct 30, 2018
@sandersn
Copy link
Member Author

Huh. This now works.

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
Projects
None yet
Development

No branches or pull requests

3 participants