Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project-wide Javascript/TypeScript language error from built-in language extension

I am getting the following error in VSCode whenever I open my workspace.

To enable project-wide JavaScript/TypeScript language features, exclude large folders with source files that you do not work on. 
Source: TypeScript and Javascript Language Feat... [BUTTON: CONFIGURE EXCLUDES]

I click the Configure Excludes button on the message and it opens the following file FRONTENDAPP/jsconfig.json

{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]}

It looks to me that is configured correctly according to the documentation below. : https://code.visualstudio.com/docs/languages/javascript

So why the error all the time?

My Workspace is setup as follows:

FOLDER: NOTES
FOLDER: FRONTENDAPP
FOLDER: BACKENDAPP

Each folder as a jsconfig.json file.

The respective file in the NOTES and BACKENDAPP is the same and looks as follows:

{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]}
like image 850
dandan Avatar asked Jan 08 '20 21:01

dandan


People also ask

How do I enable project-wide JavaScript/TypeScript language features?

To enable project-wide JavaScript/TypeScript language features, exclude large folders with source files that you do not work on. Source: TypeScript and Javascript Language Feat... [BUTTON: CONFIGURE EXCLUDES] I click the Configure Excludes button on the message and it opens the following file FRONTENDAPP/jsconfig.json

What do the error messages in typescript mean?

There is some terminology you’ll frequently see in error messages that is helpful to understand. TypeScript considers a type assignable to another type if one is an acceptable substitute for the other.

Why does typescript have such a complicated type system?

Because its type system is structural, this often means providing somewhat lengthy descriptions of where it found a problem. There is some terminology you’ll frequently see in error messages that is helpful to understand. TypeScript considers a type assignable to another type if one is an acceptable substitute for the other.

What is “wrapping exceptions” in JavaScript?

The approach is called “wrapping exceptions”, because we take “low level” exceptions and “wrap” them into ReadError that is more abstract. It is widely used in object-oriented programming. We can inherit from Error and other built-in error classes normally. We just need to take care of the name property and don’t forget to call super.


2 Answers

I had the same issues and I realized:

  1. I had node_modules in subfolders
  2. I had copies of dist (like dist1, dist2) for debugging, which where gitignored but not vscode ignored.
  3. I had .npm and .npm-tmp folders with a lot of stuff inside.
  4. Apart from dist I also had another tmp folder .app-cache.

I ended up with the following entry in /jsconfig.json (slightly redundant for readability) to make the warning go away:

  "exclude": [
    ".git",
    ".app-cache",
    ".npm",
    ".npm-tmp",
    "dist",
    "dist*",
    "node_modules",
    "subfolder/dist",
    "subfolder/node_modules",
    "**/dist/*",
    "**/node_modules/*",
  ]
}
like image 191
jakub.g Avatar answered Oct 24 '22 03:10

jakub.g


Identify folders with lots of files: du -a | cut -d/ -f2 | sort | uniq -c | sort -nr

162114 node_modules
5837 .git
4967 concat-stats-for
 443 app
  77 tests
  72 dist
   8 config
   7 public

Check folders that aren't excluded in jsconfig.json for JS and TS files

find concat-stats-for -type f | sed -e 's/.*\.//' | sort | uniq -c | sort -n | grep -Ei '(js|ts)$'

  42 ts
3003 js

If the folder isn't App code, add said folder to jsconfig.json exclude.

like image 31
dandan Avatar answered Oct 24 '22 04:10

dandan