Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS Code Typescript service reports false positive error. #55022

Closed
elliason opened this issue Jul 14, 2023 · 4 comments
Closed

VS Code Typescript service reports false positive error. #55022

elliason opened this issue Jul 14, 2023 · 4 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@elliason
Copy link

elliason commented Jul 14, 2023

In new Vite project, there is .eslintrc.cjs file with __dirname used there. If tsc is called from CLI, there is no problem but the IDE service reports this __dirname usage as error.
image
I have tried every step that came to my mind (including installing @types/node and adding types: ["node"] to tsconfig.json compilerOptions) to solve this without using // @ts-ignore, but failed everytime.

This issue occurs even without extensions.

  • VS Code Version: 1.80.1
  • OS Version: Windows 11 (22621.1992) with WSL2 - Ubuntu 22.04.2 LTS

Steps to Reproduce:

  1. run npm create vite@latest
  2. choose "typescript + swc" template
  3. check the .eslintrc.cjs file and look how __dirname error is reported
@mjbvz mjbvz transferred this issue from microsoft/vscode Jul 14, 2023
@mjbvz mjbvz removed their assignment Jul 14, 2023
@jakebailey
Copy link
Member

You need to add .eslintrc.cjs to tsconfig.node.json in vite's projects, as that's the one for config files.

image

@drewhoener
Copy link

I just ran into it this morning, appears to be a Vite issue, not TS.
Check vitejs/vite#13749 for the PR status, or copy the settings manually for an immediate fix

@elliason
Copy link
Author

@jakebailey Yes, I have done that, but the issue is still there.
image
image

Even after reloading VS Code window, no change at all.

@drewhoener This is happening on all of my projects, and some of them are not based on Vite. I just chose the Vite template as a good example. And because running tsc via CLI gives no actual error, I highly suspect the VS Code IDE.

@ts-ignoring "fixes" this but, I would really like to know where is the problem. Can't figure it out.

@RyanCavanaugh RyanCavanaugh added the External Relates to another program, environment, or user action which we cannot control. label Jul 18, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked as "External" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

6 participants