I am working with a JavaScript project, and I just wanted to know if it is necessary (or recommended) to use the jsconfig.json
file in every JavaScript project.
Will adding the jsconfig.json
file make the development process easier, or is it only used for larger JavaScript projects?
Edit: I just noticed that the jsconfig.json
file has something to do with Visual Studio Code. How does it improve the developer experience with Visual Studio Code?
CodePudding user response:
As a supplement, I’d like to say that in the official document,
the LANGUAGES-JavaScript-JavaScript projects (jsconfig.json) explains when we need this file.
the LANGUAGES-NODE.JS/JAVASCRIPT-Working with JavaScript explains its function, the parts of it, and some examples of writing this file, how to use a JavaScript support and so on.
You can refer to this : enter link description here
CodePudding user response:
The jsconfig.json
file can be used to help with IntelliSense in Visual Studio Code.
You just simply create a jsconfig.json
file in the root of your project, and add the following keys.
noLib
- Do not include the default library file (lib.d.ts
).target
- Which default module should be used (lib.d.ts
).module
- Specifies the module system, when generating module code.moduleResolution
- How modules are resolved for imports.checkJs
- Enables type checking on JavaScript files (like TypeScript).experimentalDecorators
- Enables experimental support for proposed EcmaScript decorators.allowSyntheticDefaultImports
- Allow default imports from modules with no default export. This does not affect code emit; just type checking.baseUrl
- Base directory to resolve non-relative module names.paths
- Specify path mapping to be computed relative to baseUrl option.
These all have a specific type (string
, array
, etc.), and are all in JSON format. A simple example is below (in Node.js).
{
"compilerOptions": {
"module": "commonjs",
"target": "es6"
},
"exclude": ["node_modules"]
}
In conclusion, a jsconfig.json
file can be used for IntelliSense in Visual Studio Code.