) Step by Step learning ASP. NET 5 (5)-TypeScript, asp. nettypescript

Source: Internet
Author: User
Tags sublime text

Step by step learning ASP. NET 5 (5)-TypeScript, asp. nettypescript

Forward: Microsoft MVP Lu Jianhui's article, hoping to help you. Original article: http://blog.csdn.net/kinfey/article/details/44568971

 

Editor's note: People always make mistakes multiple times. In history, I have warned you not to update the latest version of the software before the speech, but I 've made another mistake over the weekend ...... okay. Next time, I will definitely record the screen. I have made an appointment to meet you on Sunday, but I am really sorry for the delay in the coming of Shenzhen. Do you miss me? I posted four articles last week, which seems to have a good effect. Thank you for your promotion. Thank you for your support! Today, I want to talk about TypeScript. Some people think this topic has nothing to do with ASP. NET 5, but I personally think it is closely related. After all, you have to be a front-end.

What is TypeScript?

TypeScript is a JavaScript superset, which brings object-oriented and static types to JavaScript. In your project, you can inject TypeScript code without modifying any existing JavaScript code. With TypeScript, You can standardize JavaScript code and build your front-end in an object-oriented manner. TypeScript supports popular JavaScript libraries, making it easier for you to integrate with existing projects, such as Jquery, AngularJS, KnockoutJS, and NodeJS. (Go to the official website)

TypeScript environment Configuration

1. Install

Npm install-g typescript

2. Development Environment

We recommend that you install Better TypeScript through the Control Package in Sublime Text.

 

Several main features of TypeScript

1. Static type

TypeScript standardizes the declaration of JavaScript variables through static types and provides type check during compilation. For example

A class is defined here, and a getJSON method is defined in the class. Here, the parameters transmitted by the method are defined based on the static type and void is returned. If you use traditional JavaScript, although the weak type method is more convenient, the type of parameter passing is not clear. With TypeScript, you can write your front-end code like C/C ++. Here, you can replace it with any (dynamic type) when you are not specific about the object type.

2. Object-oriented

TypeScript provides interface, class, module, and other object-oriented features for JavaScript. This benefit not only standardizes the code, but also standardizes the front-end project structure. In the past, our JS projects started with traditional MVC/MVVM because JavaScript was too flexible to start with the architecture. With TypeScript, you can use object-oriented methods to integrate your front-end code.

3. ts Compiler

Tsc can be used to compile ts files of TypeScript into common JavaScript files. Of course, you can select the pre-compilation method or the real-time compilation method. Or the salty fish and cabbage have their own love, depending on their own needs. In projects, I like to use pre-compilation.

4. Third-party library support (you can obtain the TypeScript corresponding to the third-party library from here)

Now TypeScript matches all mainstream databases. You can get it from the link above nuget. The front-end of my architecture is basically based on AngularJS/KnockoutJS, And there is basically no major problem. What's even better is that AngularJS 2.0 and TypeScript have been deeply integrated (Google + Microsoft ).

 

The front-end based on TypeScript makes code writing more Cool and does not confuse you with some strange syntaxes. I like TypeScript. What about you?

 

Welcome to the anb-io subscription number of this blog. Content is pushed every week, and there are technologies and lives. We will work with you to develop a sentimental program.

Not all things in the world are maintained by direct economic contracts, such as sunshine, air, love, and open-source software.

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.