[英]add typings to javascript project
I'm using closure library, but vscode doesn't understand the goog.require statements so intellisense is kind of useless. 我正在使用闭包库,但是vscode无法理解goog.require语句,因此intellisense毫无用处。 I found typings at https://github.com/teppeis/closure-library.d.ts , and this works if I add a /// comment to the top of the file. 我在https://github.com/teppeis/closure-library.d.ts上找到了键入内容,如果我在文件顶部添加///注释,这将起作用。 But it's going to get really annoying to add this to every single file in my project. 但是将其添加到项目中的每个文件中会变得非常烦人。 Is there some way I can configure vscode to automatically reference this for all the javascript files in the project? 有什么方法可以将vscode配置为针对项目中的所有javascript文件自动引用此代码?
Try creating a jsconfig.json file at the root of your workspace: 尝试在工作区的根目录下创建一个jsconfig.json文件 :
{
"compilerOptions": {
},
"exclude": [
"node_modules"
]
}
This creates a project that will include any .js
and .d.ts
files in your workspace. 这将创建一个项目,该项目将在工作区中包含所有.js
和.d.ts
文件。 You can also explicitly manage which files are part of a project using the files
or include
jsconfig
options: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html 您还可以使用这些files
或include
jsconfig
选项来明确管理哪些文件是项目的一部分: https : jsconfig
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.