Skip to content

Incorrect ts7022 error shown in vscode (not by tsc) #195075

@martaver

Description

@martaver

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

  • 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.

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 TS Language Server repository: typescript-language-server/typescript-language-server#766

Metadata

Metadata

Assignees

Labels

info-neededIssue requires more information from poster

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions