Have you ever heard of TypeScript?
TypeScript is a hyper-set of JavaScript developed by Microsoft, TypeScript-compatible JavaScript that can be loaded into JavaScript code and then run. Typescript's progress with JavaScript includes adding comments, letting the compiler understand the supported objects and functions, removing annotations from the compiler, not increasing overhead, and adding a complete class structure that updates the traditional object-oriented language.
Why do you have TypeScript?
JavaScript is just a scripting language, not designed to develop large Web applications, and JavaScript does not provide the concepts of classes and modules, and TypeScript extends JavaScript to implement these features. TypeScript Key features include:
TypeScript is a Microsoft-launched open source language that uses the Apache licensing protocol
TypeScript is a superset of JavaScript.
TypeScript added optional types, classes, and modules
TypeScript can be compiled into a readable, standard JavaScript
TypeScript supports the development of large-scale JavaScript applications
TypeScript is designed to develop large applications and ensure compiled JavaScript code compatibility
TypeScript extends the syntax of JavaScript so that existing JavaScript code can be run directly with TypeScript without changing
The TypeScript file extension is TS, and the TypeScript compiler compiles it into a JS file
TypeScript syntax is the same as JScript. NET
TypeScript easy to learn and easy to understand
Syntax features
Class Classes
Interface Interfaces
Module Modules
Type note types annotations
Compile-time type checking Compile-checking
Arrow functions (Lambda expressions like C #)
The difference between the TypeScript of JavaScript
TypeScript is a superset of JavaScript that extends the syntax of JavaScript so that existing JavaScript code works with TypeScript without any modification, TypeScript provides compile-time static type checking through type annotations. TypeScript can process existing JavaScript code and compile only the TypeScript code in it.
Editor support
Visual Studio 2012 supports TypeScript module/syntax highlighting, which requires the installation of the TypeScript plugin. And like Sublime Text, the Vim and Emacs Editor supports syntax highlighting. Features such as refactoring and Go to Definition are also available in the VS 2012 editor.
Refactor Goto Definition, HTML application with Typescript-shemeer
Note: TypeScript does not rely on any IDE, and you can compile your TypeScript into JavaScript in any app yourself.
How to get
There are two ways to install the TypeScript:
via the node. JS Package Manager (NPM)
With the MSI inherited by Visual Studio 2012. (Click here to download)
Note: You need to close other applications to avoid some problems during installation.
The following is the interface that is installed through the MSI file:
If you just want to see TypeScript first, click here.
How to compile TypeScript
To use TypeScript in your application, you must compile the result of the compilation and compile the JS file, which you can do through the TypeScript compiler TSC.
If you use TypeScript in Visual Studio 2012, it will automatically compile the TS file into a JS file.
The TypeScript compiler template is installed in the following path:
?
1
C:\Program Files (x86) \microsoft sdks\typescript\0.8.0.0
Or is:
?
1
C:\Program Files\Microsoft Sdks\typescript\0.8.0.0
To compile the TypeScript file, you can use the following command:
?
1
TSC Filename.ts
Once the compilation is successful, a JS file with the same name will be generated in the same directory, and you can modify the default output name by using the command parameters.
If you want TypeScript to be automatically compiled, you can learn about the next Sholo.TypeScript.Build, Web Essentials 2012.
TypeScript Project/File template
Once you have installed the plugin on Visual Studio 2012, you will get the following template:
HTML Application with TypeScript
Mvc–typescript Internet Application
TypeScript File
First HTML app written in TypeScript
Now I'm starting to create a simple HTML app with TypeScript.
First create a new project through File--new-project:
Enter the necessary information and click the Ok button to create the following project template:
We will see that App.js relies on app.ts, the default App.ts file contains classes and constructors, and so on, such as:
The TypeScript file will be compiled into JavaScript (app.js), followed by the compiled JavaScript code:
Then we can reference JavaScript in the page
When you build or rebuild the project, you will see a prompt to recompile the TypeScript information:
If the.?? The following content in the Proj file will be automatically compiled:
When you run this app, the current date and time are displayed on the page
You can also play online: Playground
Playground Typescript-shemeer
More reading Information
TypeScript Microsoft Official website http://www.typescriptlang.org/
TypeScript Online Play-http://www.typescriptlang.org/Playground/
TypeScript Source Typescript.codeplex.com
Anders hejlsberg:introducing TypeScript
Summarize
In this article we briefly describe how to use TypeScript and hope that you will like or feel helpful.
VS2012 plug-in: https://visualstudiogallery.msdn.microsoft.com/fa041d2d-5d77-494b-b0ba-8b4550792b4d
VS2013 native support after SP2 version
http://www.oschina.net/question/12_72250
TypeScript Getting Started Guide