typescript-language-server / typescript-language-server

TypeScript & JavaScript Language Server

Home Page:https://www.npmjs.com/package/typescript-language-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect TS7022 error displayed by Language Server in VSCode

martaver opened this issue · comments

  • VS Code Version: 1.83.0
  • OS Version: MacOS Monterey 12.4 (but also shown in vscode on other MacOS versions)

Steps to Reproduce:

  1. Clone https://github.com/cleric-sh/repro/tree/phantom-ts7022-error-in-vscode
  2. Ensure switched to branch phantom-ts7022-error-in-vscode
  3. npm i
  4. npm compile --> observe no compiler errors
  5. Open index.ts
  6. Make a change to the file (e.g. add a space) to trigger LSP to re-analyse the file.
  7. Restart the TS Language Server and error disappears. Make a change, and error re-appears.
  8. Error should appear on value on line 26.

The error appears with all extensions disabled.

I've noted that the error is:

  • Only shown when func param 'arg' type is declared. Removing the declaration resolves the error.
  • Only shown in vscode. tsc compiles without errors.
  • Only shown on second pass, after a change has been made to the file. Initial type check on load shows no errors.
  • Only shown when noImplicitAny: true

Also, in a more complex file, declaring this function after doAnotherThing prevents the error being displayed.

All these points combined lead me to believe this is an error either in VS Code or the Typescript Language Server.

I've also created an issue in the VSCode GitHub repo: microsoft/vscode#195075

I added tsserver.log to the repro, which covers starting TS Language Server and making a change to the file.

Possibly related to issue: microsoft/vscode#177595

Based on the linked issue it seems like the issue was fixed in typescript.

Based on the repro I provided, in vscode insiders with typescript@beta, the error is still present. This issue should still be open.

It's not likely that this issue is in this server. I would suggest reporting it in the typescript repo since it reproduces with VSCode also which doesn't use this server.

I can reproduce the issue but this server is just a thin LSP layer on top of the Typescript tsserver API.

I can address issues that are specific to this LSP layer maintained here but if the issue appears to be deep in typescript's core then I'm not willing to spend hours or days of my free time debugging the issue.

Since it reproduces in VSCode, creating a bug report in Typescript repo should get the attention of the right people. It looks like an issue that is specific to the tsserver API that Typescript exposes and that's why it reproduces both in VSCode and with this server which is based on VSCode's implementation.