vtsls diagnostics gives wrong errors in Neovim
Closed this issue · 10 comments
I am using this lsp in Neovim but it seems to give me incorrect diagnostics.
For example, it will tell me in Neovim that there are unused @ts-expect-error directives but when I remove them the error that directive was covering now shows when running tsc in the terminal.
Does that make sense? Any ideas?
Have you tried vtsls.autoUseWorkspaceTsdk = true
? By default the server use the bundled version of ts and that might be different from the version installed to your project, which is possibly used by tsc running in your terminal.
Thanks for your speedy reply. That sounds like it could have been the issue but Im using LazyNvim and that is already set. I got excited for a minute.
I was able to rectify the issue by downgrading my version of Neovim. I saw the issue in 0.10.0 but not in 0.9.5!
I dont understand why but there we go. Thanks for your help
Hi @yioneko, I ran into the same bug.
Look at the screenshot:
When I reopen the file:
Have you tried vtsls.autoUseWorkspaceTsdk = true?
I'm using lazyvim. lazyvim's default configuration for vtsls has autoUseWorkspaceTsdk as true
. see: https://www.lazyvim.org/extras/lang/typescript#nvim-lspconfig
@Daydreamer-riri Not much idea about this but providing client LSP logs (:lua vim.lsp.set_log_level("DEBUG")
) for that would be helpful. We can look into textDocument/didOpen
and textDocument/publishDiagnostics
notifications to see if the issue comes from the server side.
My current guess is that this might be a issue related to typescript and you can test it in vscode to see if the results are the same. You can switch to the workspace version of typescript in vscode in Command Palette -> TypesScript: Select TypeScript Version
.
I'm pretty sure that the issue is on the server side now, but I do not have any clue regarding the case in your demo that the diagnostic report is different after the file reopening yet. Afaik the diagnostic computing of tsserver is deterministic and the server only does buffering for diagnostic fetching.
I tested @ts-expect-error
comment with simple erroneous statements before but could not reproduce the problem, so I would like to get reproducible code example for this. If you are willing to provide that, you can extract the code example similar to this:
type L = {}
type R = {}
const rhs: R = {}
// @ts-expect-error
const lhs: L = rhs;
Also please provide the typescript version which can be found by looking at the full cmd of the running tsserver path.
I can't reproduce it for the example you gave. I will try to make a minimally reproducible example.
Also regarding your comment: “ the typescript version which can be found by looking at the full cmd of the running tsserver path.”, I'm not sure how this should be obtained?
I'm not sure how this should be obtained?
I think this could work on windows in powershell:
wmic path win32_process get commandline | findstr tsserver