[typescript-ts introduction, typescript-ts features and typescript installation and use]

俗话说得好:把两只仓鼠关在一起,三个月还没有动静,只有一种可能:它们都是公的。

ts introduction and features

The author of TypeScript is Anders Hellsberg, chief architect of C#. It is an open source and cross-platform programming language.
Anders Hellsberg is currently 61 years old —November 1, 2022
TypeScript is a superset of JavaScript that mainly provides a type system and support for ES6+. It is developed by Microsoft and the code is open source on GitHub .

There are 3 main features:

From JavaScript, to JavaScript

TypeScript compiles to clean, concise JavaScript code that runs on any browser, in a Node.js environment, and in any JavaScript engine that supports ECMAScript 3 (or higher).

powerful type system

The type system allows JavaScript developers to use efficient development tools and common operations such as static checking and code refactoring when developing JavaScript applications.

Advanced JavaScript

TypeScript provides the latest and evolving JavaScript features, including those from ECMAScript 2015 and future proposals, such as asynchronous functions and Decorators, to help build robust components.

Install TypeScript

Run the following command on the command line to install TypeScript globally:

npm install -g typescript

After the installation is complete, run the following command on the console to check whether the installation is successful (3.x):

tsc -V 

write the first ts file

function greeter (person) {

  return 'Hello, ' + person
}

let user = 'Tony'

console.log(greeter(user))

The .ts extension is used, but this code is just JavaScript. On the command line, run the TypeScript compiler:

tsc helloworld.ts

The output is a helloworld.js file that contains the same JavsScript code as the input file. On the command line, run this code through Node.js:

node helloworld.js

Console output:
Hello, Tony

吕子乔早就说过:人生苦短,及时行乐才是王道。
该润就得润

Guess you like

Origin blog.csdn.net/ytfty24124/article/details/127624443