language-tools: Cannot read property 'lastIndexOf' of undefined

Since today, Volar throws errors. Volar version: v0.29.0 (updated today) vscode version: 1:62:0 (updated today)

[Error - 12:56:11] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Cannot read property 'lastIndexOf' of undefined
  Code: -32603 
[Error - 13:00:41] Request textDocument/codeAction failed.
  Message: Request textDocument/codeAction failed with message: Cannot read property 'lastIndexOf' of undefined
  Code: -32603 

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 16 (9 by maintainers)

Most upvoted comments

This appears to be related to the typescript version bundled with VSCode? Changing it to VSCode’s shipped version (4.4.3) and you see the errors. Switch it to workspace version (in our case 4.2.4), and the errors go away.

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'lastIndexOf' of undefined
    at Object.startsWith (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:2258:20)

To get a repro:

clone https://github.com/cypress-io/cypress/ checkout unified-desktop-gui yarn install open App.vue start typing in a <script setup> block

It worked in 0.28.10 but started failing in 0.29.0

Very similar but not identical error here - also since yesterday.

[Error - 10:16:15 AM] Request textDocument/codeAction failed.
  Message: Request textDocument/codeAction failed with message: Cannot read property '0' of undefined
 Code: -32603

Volar 0.29.2 vsCode 1.62.0

Changing between VSCode’s version (4.4.3) and the workspace’s version (3.9.7) only changes the error from

[Error - 12:51:01 PM] Request textDocument/codeLens failed. Message: Request textDocument/codeLens failed with message: Cannot read property '0' of undefined Code: -32603

in 4.4.3 to

[Error - 12:48:40 PM] Request textDocument/codeLens failed. Message: Request textDocument/codeLens failed with message: Cannot read property 'length' of undefined Code: -32603

for 3.9.7

packages/launchpad/src/App.vue