Skip to content

Bundled TypeScript (v2.9) has issues with auto-complete, intellisense, ctrl+click on JS projects #51626

@rfgamaral

Description

@rfgamaral
  • VSCode Version: May 2018 (version 1.24)
  • OS Version: Windows 10, Version 1803

Steps to Reproduce:

  1. Create/Open a JavaScript project with a jsconfig.json file similar to this:
{
    "compilerOptions": {
        "target": "es6",
        "moduleResolution": "node"
    },
    "exclude": [
        ".gitlab",
        ".vscode",
        "node_modules",
        "reports",
        "target"
    ]
}
  1. Open any .js file and just left-click a function name.

  2. Get this:

[Error  - 5:46:33 PM] 'occurrences' request failed with error.
Error processing request. Cannot read property 'getSourceFile' of undefined
TypeError: Cannot read property 'getSourceFile' of undefined
    at c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:90203:113
    at Object.map (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:1745:29)
    at getDocumentHighlights (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:90203:42)
    at Object.getOccurrencesAtPosition (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:90192:31)
    at IOSession.Session.getOccurrences (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:96285:64)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:95865:61)
    at c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97230:88
    at IOSession.Session.executeWithRequestId (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97221:28)
    at IOSession.Session.executeCommand (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97230:33)
    at IOSession.Session.onMessage (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97250:35)
    at Interface.<anonymous> (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:98456: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)
  1. Also, hover the mouse on a function name and get this:
[Error  - 5:49:10 PM] 'quickinfo' request failed with error.
Error processing request. Cannot read property 'getSourceFile' of undefined
TypeError: Cannot read property 'getSourceFile' of undefined
    at getValidSourceFile (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:89815:37)
    at Object.getQuickInfoAtPosition (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:89988:30)
    at IOSession.Session.getQuickInfoWorker (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:96629:62)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:95719:61)
    at c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97230:88
    at IOSession.Session.executeWithRequestId (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97221:28)
    at IOSession.Session.executeCommand (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97230:33)
    at IOSession.Session.onMessage (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97250:35)
    at Interface.<anonymous> (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:98456: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)
  1. And as a last example, try to Alt+Click a function name on an import statement and get this:
[Error  - 5:50:20 PM] 'definition' request failed with error.
Error processing request. Cannot read property 'getSourceFile' of undefined
TypeError: Cannot read property 'getSourceFile' of undefined
    at getValidSourceFile (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:89815:37)
    at Object.getDefinitionAtPosition (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:90153:105)
    at IOSession.Session.getDefinition (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:96208:64)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:95679:61)
    at c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97230:88
    at IOSession.Session.executeWithRequestId (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97221:28)
    at IOSession.Session.executeCommand (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97230:33)
    at IOSession.Session.onMessage (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:97250:35)
    at Interface.<anonymous> (c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:98456: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)

For each different action there's a different error:

  • [Error - 5:46:33 PM] 'occurrences' request failed with error.
  • [Error - 5:49:10 PM] 'quickinfo' request failed with error.
  • [Error - 5:50:20 PM] 'definition' request failed with error.

Does this issue occur when all extensions are disabled?: Yes

Workaround available?

  1. Install TypeScript v2.8.3 globally (e.g: npm -g install [email protected], or typescript@next also seems to work just fine).
  2. Configure your typescript.tsdk user setting to point to that version (e.g: "typescript.tsdk": "C:\\Users\\AmaralR\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib"
  3. Use Ctrl+Shift+P and pick TypeScript: Select TypeScript Version.
  4. You'll see your globally installed version on the list, select that.
  5. TypeScript Standalone Server will relaunch in the background with that version.
  6. Profit!

Metadata

Metadata

Assignees

Labels

info-neededIssue requires more information from postertypescriptTypescript support issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions