npm安装
npm install -g typescript
ts文件转化成js文件:tsc + ts文件路劲
类型注解在TypeScript中是记录函数或变量约束的简便方法。例子:person: string
接口:interface Person { firstName: string; lastName: string; }
接口的使用:interface Person { firstName: string; lastName: string; }
function greeter(person: Person) { return "Hello, " + person.firstName + " " + person.lastName; }
var user = { firstName: "Jane", lastName: "User" };
document.body.innerHTML = greeter(user);