Using Typings to implement smart hints for visual Studio code

Source: Internet
Author: User
Tags install node
Objective

I'm sure you all know that smart hints for code in the IDE are almost always standard, although some text editors have some simple hints, but this is provided by code Snippets. It is far more functional than the IDE. However, the recent rise of the text editor of the new sharp Visual Studio Code can be typings to the JavaScript to implement smart hints, for a text editor, this is very rare. So visual Studio Code is particularly well-suited for writing JavaScript (node. js) programs; At the same time, if we need to write some small, tentative snippets of code, such as: Lodash.js a small demo of a function, because we do not want to study how a function is used to create a new project using the IDE, Visual Studio Code is a very good choice, And it can also run and debug JavaScript code (depending on node. js), and it also contains very handy code hinting functionality.

From this point of view, I think visual Studio Code is already a small and lean IDE.

Installing typings with NPM

With NPM we can easily install typings and enter it on the command line:

NPM install-g typings

After the installation is complete, on the command line, enter:

Typings--version

Seeing the version information indicates that the Typings tool installation is complete:

NPM is installed with node. js, and if you want to use NPM, you should install node. JS first.

Install the relevant message file

After the installation is complete, we need to install the appropriate function library or framework type information file, here we create a new folder Nodesnippet, using the command line into the directory, enter the following two commands to install node and Lodash type interface information file:

Typings Install Dt~node--global--savetypings install Lodash--save

When to use the--global parameter:

If the installed package uses a script tag to reference (for example, jquery) (that is, it is used in the browser)

When this package is part of the environment (such as node)

The package does not use--global when the installation fails

At this point we can see some more files in our Nodesnippet directory:

These files are type-type files (defined using typescript) that provide us with prompt information. To see if typings supports smart hints for a library or framework, we can use the following command:

Typings Search Examplename

Enable Smart hints feature

There are two ways to start the prompt function:

The first is in the need to make only the tip of the file the most upstream add hint information file directory, the format is as follows:

<reference path= "./typings/index.d.ts"/>

The second is to add an empty file named Jsconfig.json in the directory where the project is located (in the Nodesnippet folder, in this case).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.