简体   繁体   中英

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. 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. 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?

Try creating a jsconfig.json file at the root of your workspace:

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

This creates a project that will include any .js and .d.ts files in your workspace. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM