如何使用ts1.安装 Node.jsTS 最终要编译成 JS 运行先装 Node.js自带 npm验证终端输入node -v和npm -v能显示版本就装好了。2.安装 TypeScript终端执行运行npm install -g typescript验证输入tsc -v显示版本号比如 5.3.3就成功了。3. 第一个 TS 程序入门示例① 创建文件hello.ts后缀是.ts写入typescriptconst userName: string TS新手; function say(person: string): string { return 你好${person}这是第一个TS程序; } console.log(say(userName));② 编译 TS 为 JS终端进入文件所在目录执行tsc hello.ts会生成hello.js文件TS 编译后的 JS 代码。③ 运行 JS运行node hello.js输出你好TS新手这是第一个TS程序。执行命令tsc xxx.ts运行JS node xxx.js如果想要在页面上运行 创建一个index.html,把js导入进去index.html!DOCTYPEhtmlhtmllangenheadmetacharsetUTF-8metanameviewportcontentwidthdevice-width, initial-scale1.0titleDocument/title/headbodyscriptsrchello.js/script/*导入js*//body/html