gpt4 book ai didi

intellisense - VSCode - 为什么 tsconfig.json 必须在根目录中才能自动完成?

转载 作者:行者123 更新时间:2023-12-04 13:48:30 24 4
gpt4 key购买 nike

根据 typescript 文档

The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.



在我的理解中,这意味着我可以有一些像下面这样的应用程序结构
+-- app
| +-- src
| +-- controllers
| +-- AppCtrl.ts
| +-- application.ts
| +-- tsconfig.json
| +-- assets

我注意到这是为新 .ts 自动完成的唯一方法文件是创建另一个 tsconfig.json在我的根目录,比如
+-- app
+-- tsconfig.json
| +-- src
| +-- controllers
| +-- AppCtrl.ts
| +-- application.ts

在第一个结构中,如果我 ,我可以获得自动完成功能创建新的 ts 文件后重新加载 IDE .

vscode 中是否需要一些配置才能使第一个结构正常工作,或者这是错误的?

更新 :我也没有在打开根目录中的文件时自动完成。重新启动 IDE 似乎可以修复它,但不是每个创建的新文件的选项......

vscode autocomplete error

最佳答案

在 VSCode 中,您打开的文件夹是根文件夹。如您引用的文本中所述, tsconfig.json 必须在该文件夹中。就这么简单。

关于intellisense - VSCode - 为什么 tsconfig.json 必须在根目录中才能自动完成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38840960/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com