Typescript学习

–> npm show typescript
–> npm install -g typescript
–> tsc -v
–> npm bin -g
Typescript学习
tsc命令:
–> tsc --help
–>tsc --outDir dist helloworld.ts
Typescript学习
–>tsc --outDir dist ./src/helloworld.ts
Typescript学习
–>tsc --init
注:修改之后只需 --> tsc
Typescript学习

动态监视,自动编译

–>tsc -w
Typescript学习

变量使用前要定义

Typescript学习
Typescript学习

变量类型

number:数值型
string: 字符串
boolean:布尔型
symbol:符号型,标识唯一对象
any :任意类型
object:对象类型。(数组,元祖,类,接口,函数等)
Typescript学习

any类型

Typescript学习

var和let

1. 限定变量的作用范围

var

Typescript学习

let

Typescript学习
2. 防止变量的重复定义

var

Typescript学习

let

Typescript学习

常量

Typescript学习

数组常量

Typescript学习
Typescript学习

数组

Typescript学习

二维数组

Typescript学习

枚举

Typescript学习

联合类型

Typescript学习

null空检查

Typescript学习
–> tsc --help
严格空检查
–> cls:清屏
Typescript学习