I found that a Vue project that did not use TS had some type checking problems, but I couldn’t find out where the configuration problems were. I accidentally found that there was an extra jsconfig.json file different from other projects, and I deleted it decisively after leaving the record, emMM, and found that the type checking problems were gone. The jsconfig.json file is used to check the contents of the jsconfig.json file.

Jsconfig. Json is what

The presence of a jsconfig.json file in the directory indicates that the change directory is the root of the JavaScript project. The jsconfig.json configuration allows you to personalize all js code in the directory where your files reside. Jsconfig. json is a subset of tsconfig.json.

If a tsconfig.json file exists in a directory, it means that the directory is the root of the TypeScript project. The tsconfig.json file specifies the root file and compilation options to compile this project

Why do WE need jsconfig.json

Visual Studio Code’s JavaScript support can be run in two different modes:

  • File scope – No jsconfig.json: In this mode, JavaScript files opened in Visual Studio Code are treated as separate units. As long as file A.js does not explicitly reference file b.ts (using /// reference directives or CommonJS modules), there is no common project context between the two files.
  • Explicit projects – Using jsconfig.json: JavaScript projects are defined through jsconfig.json files. The presence of such a file in a directory indicates that the directory is the root of your JavaScript project. The files themselves can choose to list files that belong to the project, files to exclude from the project, and compiler options (see below)

The JavaScript experience is improved when you specify a jsconfig.json file in your workspace.

  • Json is a subset of tsconfig.json, so the check is ts.
  • When we use the webPack alias in our project, we find that there is no way to jump to the corresponding file, which can be configured in jsconfig.json

Jsconfig. Json configuration

You can refer to the tsconfig.json configuration file

Json {"compilerOptions": {"target": "es2015", // Specify the default library to use. The values are "ES3 "," ES5 "," ES2015 "... "Module ": "commonjs", // specify module system "checkJs": false when generating module code, // enable javascript file type checking "baseUrl": "Paths ": {"utils": [" SRC /utils/*"] // Specifies the path map computed relative to the baseUrl option, using the Webpack alias, intellisom path}}, "exclude": [/ / to exclude files "node_modules", "/ node_modules / * * *]", "include:" [/ / contains files "SRC / *. Js]}Copy the code
"compilerOptions": { "incremental": TsBuildInfoFile: tsBuildInfoFile: tsBuildInfoFile: tsBuildInfoFile: tsBuildInfoFile: "./buildFile", // Store the incremental compiled file at "diagnostics": true, // Print the diagnostic information "target": "ES5", // Version of the target language "module": "CommonJS", // generate code template standard "outFile": "./app.js", // generate multiple dependent files into a file, can be used in AMD modules, that is, should be set to "module": "AMD", "lib": ["DOM", "ES2015", "ScriptHost", "es209.array "], // The library that TS needs to reference, that is, the declaration file, ES5 default reference DOM, ES5, ScriptHost, if you need to use es advanced version features, usually need to configure. Array", "allowJS": true, // allows the compiler to compile JS, JSX file "checkJs": True, // Allow errors in JS files, usually with allowJS using "outDir": "./dist", // specify output directory "rootDir": "./", // Specify the output directory (for output), which controls the structure of the output directory "declaration": true, "./file", // Specify "emitationonly ": true, // only declare file, not js file" sourceMap": // Generate target file sourceMap file "inlineSourceMap": Inline SourceMap is included in the generated JS file "declarationMap": true, // The SourceMap "typeRoots" is generated for the declaration file: [], // declare file directory, default node_modules/@types "types": [], "NoEmitOnError ": true, "noEmitHelpers": // Do not generate the helper function, reduce the volume, require additional installation, usually with importHelpers" importHelpers": True, // Introduce a helper function via tslib, the file must be the module "downlevelIteration": true, // The degraded traverser implementation, if the target source is ES3/5, then the traverser has the degraded implementation "strict": True, // turn on all strict type checking "alwaysStrict": true, // inject 'use strict' "noImplicitAny" into the code: StrictNullChecks: true, strictNullChecks: true, strictFunctionTypes: strictNullChecks: true, strictNullChecks: true, strictNullChecks: true, strictFunctionTypes: True, / / do not allow two-way covariance function parameters "strictPropertyInitialization" : true, / / class instance attributes must be initialized "strictBindCallApply" : NoImplicitThis: true, // Strict bind/call/apply checks "noImplicitThis": true, // does not allow this to have an implicit any type "noUnusedLocals": True, / / inspection declaration, only the unused local variable (only tip is not an error) "noUnusedParameters" : true, / / check unused function parameters (tip is not only an error) "noFallthroughCasesInSwitch" : "NoImplicitReturns ": true, // Each branch will return the value "esModuleInterop": True, // Allow export= export, import from import "allowUmdGlobalAccess": true, // allow global access to the umD module "moduleResolution": "Node ", // the default path for modules is "baseUrl": "./", // The default path for non-relative modules is "paths": {// Path mapping, relative to baseUrl // If you do not want to use the default jQ version and need to specify the version manually, you can configure "jquery" as follows: ["node_modules/jquery/dist/jquery.min.js"] }, "rootDirs": [" SRC ","out"], // Put multiple directories in a virtual directory, which can be used at runtime, i.e. the location of imported files may change after compilation. This can also be set to the same directory SRC and out, no need to change the path and no error "listEmittedFiles": True, // Prints output files "listFiles": true// prints compiled files (including referenced declaration files)}Copy the code

Refer to the article

www.jianshu.com/p/f82d9d11c… Code.visualstudio.com/docs/nodejs… www.jianshu.com/p/0383bbd61…