简体   繁体   English

如何将api添加到Visual Studio代码

[英]How to add an api to Visual Studio Code

I am new at using Visual Studio Code and I am looking to add an api library that I have to VS code so that the Javascript IDE can provide intellisense code completion. 我是使用Visual Studio Code的新手,我想为VS代码添加一个API库,以便Javascript IDE可以提供智能感知代码完成。

In the past I used Eclipse IDE and added the file to my libs folder in my workspace. 过去,我使用Eclipse IDE,并将文件添加到工作区中的libs文件夹中。 This doesn't seem to be the case for VS Code. VS Code似乎并非如此。

The file is a just a .js file that contains a javascript "skeleton" for the API that is intended to be used in a Javascript IDE. 该文件只是一个.js文件,其中包含打算在Javascript IDE中使用的API的javascript“骨架”。

Here is a link to the file. 这是文件的链接。 https://www.dropbox.com/s/5ywltqbi7ar0pfa/concept_api.js?dl=0 https://www.dropbox.com/s/5ywltqbi7ar0pfa/concept_api.js?dl=0

You can add a comment to the top of your file pointing to the "skeleton": 您可以在文件顶部添加指向“骨骼”的注释:

/// <reference path="./api.js">

VS Code should even give you code completion in the path string. VS Code甚至应该在path字符串中为您提供代码完成。

Create a jsconfig.json file in the root of your Visual Studio Code project and add all files you want parsing for code completion. 在Visual Studio Code项目的根目录中创建一个jsconfig.json文件,然后添加要解析以完成代码的所有文件。

{
    "include": [
        "www/js/*.js",
        "www/lib/*.js"
    ]
}

JavaScript Programming with Visual Studio Code 使用Visual Studio Code进行JavaScript编程

As of the above page VS Code's intellisense is provided using TypeScript. 从上一页开始,使用TypeScript提供了VS Code的智能。 It is recommended that you create Typings for your library if you are planning to ship the library. 如果计划运送库,建议您为库创建打字。

But adding a comment like 但是添加像

/// <reference path="you_file.js"> /// <reference path =“ you_file.js”>

will give you some help with code completion but the accuracy of the completion is a question. 将为您提供一些有关代码完成的帮助,但是完成的准确性是一个问题。

If you are planning to ship the library 如果您打算运送图书馆

Visit This page for more help 访问此页面以获取更多帮助

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

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