美文网首页
VS Code 创建 TypeScript 项目

VS Code 创建 TypeScript 项目

作者: 敲代码的本愿 | 来源:发表于2021-11-11 14:48 被阅读0次

TypeScript

  1. 安装:
npm install -g typescript
  1. 版本号:
tsc -v

创建项目

//项目结构
demo/
    ├─ src/
    │    ├─ css/
    │    ├─ fonts/
    │    ├─ images/
    │    └─ index.ts
    ├─ index.html
    ├─ package.json
    └─ tsconfig.json
  1. 创建 package.json
npm init
  1. 创建 tsconfig.json
tsc --init
  1. 安装 live-server
npm install -g live-server
  1. 修改 package.json
"scripts": {
    "start": "tsc -w & live-server"
  }
  1. 启动项目
npm start

ts 编译 js

tsc xxx.ts

监控自动编译

tsc -w

相关文章

网友评论

      本文标题:VS Code 创建 TypeScript 项目

      本文链接:https://www.haomeiwen.com/subject/outgzltx.html