Skip to content

Crash in JS constructors initialized with intermediate module.exports assignment #37194

Closed
@DanielRosenwasser

Description

@DanielRosenwasser
// @filename: foo.js
var /*definition*/Foo = module.exports = function () {

}

Foo.prototype.blah = function() {

}

new Foo/*use*/()

Go to definition on /*use*/.

Expected: cursor navigates to /*definition*/
Actual:

Debug Failure. Expected declaration to have at least one class-like declaration
Error: Debug Failure. Expected declaration to have at least one class-like declaration
    at getConstructSignatureDefinition (...\TypeScript\lib\tsserver.js:115538:89)
    at getDefinitionFromSymbol (...\TypeScript\lib\tsserver.js:115533:20)
    at getDefinitionAtPosition (...\TypeScript\lib\tsserver.js:115340:32)
    at Object.getDefinitionAndBoundSpan (...\TypeScript\lib\tsserver.js:115457:31)
    at Proxy.getDefinitionAndBoundSpan (...\TypeScript\lib\tsserver.js:135385:38)
    at IOSession.Session.getDefinitionAndBoundSpan (...\TypeScript\lib\tsserver.js:144925:83)
    at Session.handlers.ts.createMapFromTemplate._a.<computed> (...\TypeScript\lib\tsserver.js:144251:61)
    at ...\TypeScript\lib\tsserver.js:145957:88
    at IOSession.Session.executeWithRequestId (...\TypeScript\lib\tsserver.js:145948:28)
    at IOSession.Session.executeCommand (...\TypeScript\lib\tsserver.js:145957:33)
    at IOSession.Session.onMessage (...\TypeScript\lib\tsserver.js:145981:35)
    at Interface.<anonymous> (...\TypeScript\lib\tsserver.js:147296:27)
    at Interface.emit (events.js:200:13)
    at Interface._onLine (readline.js:314:10)
    at Interface._normalWrite (readline.js:459:12)
    at Socket.ondata (readline.js:170:10)
    at Socket.emit (events.js:200:13)
    at addChunk (_stream_readable.js:294:12)
    at readableAddChunk (_stream_readable.js:275:11)
    at Socket.Readable.push (_stream_readable.js:210:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)```

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputDomain: JavaScriptThe issue relates to JavaScript specificallyEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions