Skip to content

Exception from convertToImportCodeFixContext #21607

@rbuckton

Description

@rbuckton

TypeScript Version: 2.7.0-insiders.20180117
VSCode Version: 1.20.0-insider

Exception in convertToImportCodeFixContext when the TS extension runs getCodeFixes.

Repro Steps:

  1. Open a new TS file with the following content:
const x = y;
  1. Ensure the Output Pane is open with the TypeScript extension output selected.
  2. Select the contents of the entire file (e.g. Ctrl+A on Windows)
  3. Comment the selected range (e.g. Ctrl+/ on Windows)

Expected Behavior:
No output to extension log.

Actual Behavior:
The following is output to the extension log:

Error: Debug Failure. Invalid cast. The supplied value did not pass the test 'isIdentifier'.
    at Object.cast (c:\dev\TypeScript\built\local\tsserver.js:2445:15)
    at convertToImportCodeFixContext (c:\dev\TypeScript\built\local\tsserver.js:78598:34)
    at Object.getImportCodeActions [as getCodeActions] (c:\dev\TypeScript\built\local\tsserver.js:79002:36)
    at c:\dev\TypeScript\built\local\tsserver.js:77474:33
    at Object.forEach (c:\dev\TypeScript\built\local\tsserver.js:1430:30)
    at Object.getFixes (c:\dev\TypeScript\built\local\tsserver.js:77473:16)
    at c:\dev\TypeScript\built\local\tsserver.js:83621:35
    at Object.flatMap (c:\dev\TypeScript\built\local\tsserver.js:1700:25)
    at Object.getCodeFixesAtPosition (c:\dev\TypeScript\built\local\tsserver.js:83619:23)
    at IOSession.Session.getCodeFixes (c:\dev\TypeScript\built\local\tsserver.js:90643:64)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (c:\dev\TypeScript\built\local\tsserver.js:89547:61)
    at c:\dev\TypeScript\built\local\tsserver.js:90808:88
    at IOSession.Session.executeWithRequestId (c:\dev\TypeScript\built\local\tsserver.js:90799:28)
    at IOSession.Session.executeCommand (c:\dev\TypeScript\built\local\tsserver.js:90808:33)
    at IOSession.Session.onMessage (c:\dev\TypeScript\built\local\tsserver.js:90828:35)
    at Interface.<anonymous> (c:\dev\TypeScript\built\local\tsserver.js:92029:27)
    at emitOne (events.js:96:13)
    at Interface.emit (events.js:191:7)
    at Interface._onLine (readline.js:241:10)
    at Interface._normalWrite (readline.js:384:12)
    at Socket.ondata (readline.js:101:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions