vscode: typescript/lib/lib.d.ts not found in all jsconfig.json files without target
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.74.0 and 1.75.0-insider
- OS Version: Windows 11 x64 10.0.22621
Every project on my local system containing a jsconfig.json file without a target property has started reporting this error:
File 'd:/Program Files/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.d.ts' not found.
The file is in the program because:
Default library for target 'es3'
Some projects have it multiple times, others only once. I freshly installed insiders to test, with no settings or extensions, and it occurs there too.
It doesn’t occur if you have target
as one of your compiler options, but this wasn’t necessary before. My code isn’t compiled with typescript; I use jsconfig so vscode recognizes my files as being part of the same project, and other similar reasons.
Working as normal when target is specified:
Examples of the issue:
Steps to Reproduce:
- Open an empty folder in vscode
- Create an empty index.js file
- Create a jsconfig.json with valid properties without specifying a compiler options target.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 19
- Comments: 27 (1 by maintainers)
Commits related to this issue
- Make sure `lib.d.ts` is included in build Fixes #168420 — committed to mjbvz/vscode by mjbvz 2 years ago
- Make sure `lib.d.ts` is included in build Fixes #168420 — committed to mjbvz/vscode by mjbvz 2 years ago
- Make sure `lib.d.ts` is included in build (#168519) Fixes #168420 — committed to microsoft/vscode by mjbvz 2 years ago
- Squashed commit of the following: commit f63eaa61fb7e4599824574add2e29ae5e677cf77 Author: SteVen Batten <6561887+sbatten@users.noreply.github.com> Date: Sat Dec 10 08:41:45 2022 -0800 remove f... — committed to EngineLessCC/vscode by EngineLessCC 2 years ago
- Aggiunto target per elimiare warning. https://github.com/microsoft/vscode/issues/168420#issuecomment-1346336480 — committed to giapelle/meteor-wallet by giapelle 2 years ago
- build(vscode): update jsconfig.json suppress the error message: see https://github.com/microsoft/vscode/issues/168420#issuecomment-1345260710 — committed to masakudamatsu/mima by masakudamatsu 2 years ago
I also had this error in
tsconfig.node.json
. I restarted TS Server in VSCode and then it fixed.cmd + shift + p
Added
"target": "esnext"
and now it just works.Here is what worked for me!
Close the VS Code.
yarn global add next@latest
yarn global add typescript@latest
Open your project
rm -rf node_modules package-lock.json
Re-open your project!
Also, check your VS Code extension, Install the official Javascript & Typescript extension by Microsoft.
I hope this helps!
I tried this, but it didn’t work for me. I thought I was the only one with this issue after updating VS Code.
EDIT: So, what I did to fix this issue was copy a lib.d.ts file from a recent project I worked on to the lib directory. The error was no longer present after saving via the jsconfig.json file.
Before:
After:
EDIT #2: I downloaded an older version of VS Code for macOS (1.73.1) and copied the file from Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.d.ts. The reason was because the current version (1.74.0) did not have the file in the lib directory. I observed some of the lib.d.ts files on my Mac were different. The file in the lib directory looks like this:
Here is the code:
Thanks man. It’s worked for me.
Thanks @sagargulati I just install the extension and with that works
Seems fixed on Update 1.74.1. Thanks!
Added “target”: “ESNext” and now it just works. { “compilerOptions”: { “target”: “ESNext”, “composite”: true, “module”: “ESNext”, “moduleResolution”: “Node”, “allowSyntheticDefaultImports”: true }, “include”: [“vite.config.ts”] }
I just did
cmd + shift + p
and used the Workspace version instead of VS Code. It worked.
Same question, when creating vite project:
9 Errors in
tsconfig.node.json
:Thank you @sagargulati. Installing the extension and restarting VSCode worked for me.
It worked for me too 😃
I am also having this issue on Mac Ventura. Restarting the Typescript server or even restarting VS Code only solves the problem for a few minutes, then it resurfaces.
Igual me esta pasando, de la nada salio el problema.
Problem fixed on Update@1.74.1
add “target”: “esVersion” with esVersion like es6, es2017, es2020, … in compilerOptions this worked for me 😃
This worked for me. Thanks