typescript是基于javascript的强类型标记性语言,使用typescript语言可开发出不同规模的、易于扩展的web前端页面应用,本文主要描述typescript的开发环境搭建。
|---------------------------|
| npm install -g typescript |

如上所示,在本地开发环境中,使用nodejs运行时环境、使用npm包管理工具、使用npm安装typescript编译环境,typescript编译环境主要用于将typescript文件转换成javascript文件
typescript编译



如上所示,在本地开发环境中,使用typescript的编译环境将typescript的文件greeter.ts编译成javascript的文件greeter.js
typescript类型标记


如上所示,typescript编译环境在编译期间对代码执行类型检查,很明显地,person是字符串强类型标记,user是数组类型,字符串与数组是不同的类型参数,因而发生类型不兼容的编译错误
typescript接口类型

如上所示,在本地开发环境中,定义一个person接口类型、user在内部结构的形态上是接口person的一个具体实现,因而,user与person是相同的对象类型
typescript类类型

如上所示,在OOP面向对象编程模型中,在内部结构的形态上,类student是接口person的一个具体实现,因而student与person是兼容类型