前言1.适合初学者;2.文档看一千遍不如手把手过一遍。看了文档很多次都忘记了;我建议你边看边运行演示。三、官网在线运行地址:https://www.typescriptlang.or...1、如何自动执行ts文件?使用ts-node直接运行TypeScript代码npminstall-gts-nodets-nodedemo1.ts2,函数类型为函数functionsanitizeInput(str:string):string{returnstr+',arden';}console.log(sanitizeInput('hi'));3.Interface和type的共同点和区别1)共同点可以声明类型interfacePoint{x:number;y:number;}//typePoint{//x:number;//y:number;//}functionprintCoord(pt:Point){console.log("坐标的x值为"+pt.x);console.log("坐标的y值为"+pt.y);}printCoord({x:100,y:200});2)列出了不同类型的扩展方法Binterface可以通过extensions为现有类型添加新字段parenttype扩展类型不能通过parenttype扩展&{}Addnewfieldreferencelinktoexistinginterfacehttps://www.typescriptlang.组织
