Using Typescript in your project

Source: Internet
Author: User

The new version of Visual Studio has good support for typescript, and we can add the typescript file directly to the project, and the IDE will automatically generate the JS file to the TS file's sibling directory while writing the typescript code (note that it only generates , you need to add them to the project manually).

However, using a class library that is already in the project, such as jquery, in typescript, you need to add a claim file (*.d.ts) to the project directory, otherwise IntelliSense will not work correctly.

In addition to writing your own declaration files, there are open source projects such as definitelytyped, which provide typescript declaration file downloads for various class libraries. In addition, there is a simple way to manage the project's declaration file through TSD, which briefly describes the installation and use of TSD (provided that node is already installed):

1. Installing TSD

Npm-g Install TSD

2. Navigate to the Scripts directory

CD d:\***\scripts

3. Initialize, a Tsd.json file and a typings directory will be created in the directory to hold the obtained claim file.

TSD Init

4. Get jquery

TSD Install jquery

As you can see, a jquery folder has been created automatically in the Typings directory, which is the declaration file.

5. More information on how to use TSD can be viewed through the following instructions:

TSD--help

Using Typescript in your project

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.