How to extend VSCode code completion with a third-party JavaScript library

旧巷老猫 提交于 2020-05-13 14:31:06

问题


In my projects I use a third-party JavaScript library. I cannot import it explicitly in my code, this library is provided by JavaScript engine at runtime. I want to make coding easier by extending VSCode Intellisense by this library on all my project. I have a JavaScript file with function signatures of this library. What are the ways to do this? I already tried:

  1. write /// <reference path=''> to file in project. It works but it’s not very convenient to write it in all files.
  2. use jsconfig.json file. This method did not work for me. Maybe I did
    something wrong.
  3. create extension with vscode.codeCompletionProvider. It works but VSCode does not perceive the input code as an object, interpreting it like text.
    That's why after dot symbol VSCode offers other text that I entered as part of the program and my completion item located below this
    text.

I have the following directory structure

.
├── project1
│   ├── ...
│   └── modules
├── project2/
│   ├── ...
│   └── modules
├── projectN/
│   ├── ...
│   └── modules
├── types
│   └── lib.js (file that I want to add to Intellisense)
├── .gitignore
└── jsconfig.json

And I tried the following file contents of jsconfig.json:

{
   "include": ["types/**/*"] // (also tried ["types/lib.js"] and ["types/**/*.js"])
}

Please help to deal with this issue. Maybe I'm missing something. Is there a way to expand the Intellisense? Thanks

来源:https://stackoverflow.com/questions/57981266/how-to-extend-vscode-code-completion-with-a-third-party-javascript-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!