文档简介 · TypeScript中文网 (opens new window)
深入理解 TypeScript | 深入理解 TypeScript (opens new window)
# 基础环境搭建
安装
npm install -g typescript
编译
// demo.ts
function hello() {
let str: string = "ts";
console.log(str);
}
hello();
tsc demo.ts
生成 demo.js
运行
node demo.js
编译并运行
npm install -g ts-node
ts-node demo.ts
# 初始化一个项目
技术胖-TypeScript 从入门到精通图文视频教程-免费教程 (opens new window) - 搭建浏览器开发环境步骤
npm init -y
tsc init