chore(language-service): improve global types error message for JS projects #5574
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Description
Improved the global types error message to be more inclusive and helpful for both JavaScript and TypeScript projects.
Changes
"exclude": ["node_modules"]when creating new config files to maintain VS Code performanceMotivation
Problem Background
When users are in a non-npm like environment, they may be missing both the node_modules directory and TypeScript/JavaScript configuration files. The previous error message only mentioned
tsconfig.json, which could confuse JavaScript developers who usejsconfig.json.Performance Risk
More importantly, according to VS Code official documentation, VS Code will by default exclude the node_modules folder to optimize performance when there is no jsconfig.json in the workspace. When users create a new jsconfig.json to configure
vueCompilerOptions.globalTypesPathfollowing the error prompt, this changes VS Code's default behavior.Potential Issues
If JavaScript project users don't explicitly add
"exclude": ["node_modules"]when creating jsconfig.json, then when they subsequently install npm dependencies, the TypeScript/JavaScript language service will scan the entire node_modules directory, which may cause performance issues.Solution
This improvement ensures that the prompt message is preventive and comprehensive, specifically targeting the performance risks of jsconfig.json, while maintaining unified recommendations for both types of configuration files, allowing users to solve the current problem without accidentally breaking VS Code's default performance optimization mechanism due to our suggestions.
Testing
References