简体   繁体   English

由于缺少绿色灯泡,因此无法在Visual Studio中自动创建jsconfig.json

[英]Can't auto create jsconfig.json in Visual studio as green bulb is missing

I want to create a jsconfig.json file, but Visual studio is not showing me the green bulb that allows me to do this. 我想创建一个jsconfig.json文件,但是Visual Studio并未向我展示允许我执行此操作的绿色灯泡。 I'm used to finding the green bulb at the bottom right of the editor like this image is showing. 我习惯于在编辑器右下角找到绿色灯泡,如该图所示。

这样,但我没有

Why can't I see the green bulb? 为什么看不到绿色灯泡?

Writing jsconfig.json 编写jsconfig.json

When VS Code detects that you are working on a JavaScript file , it looks to see if you have a JavaScript configuration file jsconfig.json in your workspace. 当VS Code 检测到您正在处理JavaScript文件时 ,它会查看您的工作区中是否有JavaScript配置文件jsconfig.json。 If it doesn't find one, you will see a green lightbulb on the Status Bar prompting you to create one. 如果找不到,您将在状态栏上看到绿色的灯泡,提示您创建一个。 Click the green lightbulb and accept the prompt to create a jsconfig.json file. 单击绿色灯泡并接受提示以创建jsconfig.json文件。 ( source ) 来源

It looks like the availability of the green lightbulb is determined by the currently opened file being a javascript file. 看起来绿色灯泡的可用性取决于当前打开的文件是javascript文件。

Otherwise just create a jsconfig.json file yourself: 否则,您自己创建一个jsconfig.json文件:

{
    "compilerOptions": {
        "target": "ES6"
    },
    "exclude": [
        "node_modules"
    ]
}

TypeScript now infers the JavaScript project if no jsconfig.json is found. 现在,如果找不到jsconfig.json TypeScript会推断JavaScript项目。 This means that the green light bulb hint about creating a jsconfig.json file is not required so it was removed from vscode in November iteration (1.7.0 or 1.7.1). 这意味着不需要绿色灯泡提示有关创建jsconfig.json文件的信息,因此已在11月迭代(1.7.0或1.7.1)中将其从vscode中删除。 The vscode documentation was not yet updated to reflect that change. vscode文档尚未更新以反映该更改。

Related PR: vscode/pull/15213 Related plan item: vscode/issues/15205 相关PR: vscode / pull / 15213相关计划项目: vscode / issues / 15205

tl;dr Starting from vscode 1.7.1 you don't need the jsconfig.json file unless you are overwriting/extending default setting. tl; dr从vscode 1.7.1开始,除非覆盖/扩展默认设置,否则不需要jsconfig.json文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为 Visual Studio Code 创建一个“jsconfig.json”文件 - Creating a 'jsconfig.json' file for Visual Studio Code 什么是jsconfig.json? - What is jsconfig.json? Visual Studio 代码“Cick-Through / Go-To”不适用于 jsconfig.json(和 Next.js)中的路径别名 - Visual Studio Code “Cick-Through / Go-To” does not work with path aliases in jsconfig.json (and Next.js) 有没有办法为 svelte 中的绝对路径创建配置文件(指定编译器选项),就像我们可以为 javascript 项目使用 jsconfig.json - Is there a way to create config file(to specify compiler options) for absolute paths in svelte like we can have jsconfig.json for javascript projects 在 VueJS 项目中设置 jsconfig.json - set jsconfig.json in a VueJS project 'import-resolver-typescript/lib' 在 jsconfig.json 中找不到错误 - 'import-resolver-typescript/lib' not found error in jsconfig.json 在 JSConfig.json 文件中看到未知的 typescript 错误 - Seeing unknown typescript error in JSConfig.json file 如何在react-native项目中启用jsconfig.json - How to enable jsconfig.json in react-native project VS Code jsconfig.json 似乎什么也没做 - VS Code jsconfig.json does not seem to do anything ES 模块和 jsconfig.json:错误 [ERR_MODULE_NOT_FOUND] - ES modules and jsconfig.json: Error [ERR_MODULE_NOT_FOUND]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM