搭建 Server 端 Typescript 开发环境
搭建 Server 端 Typescript 开发环境
由 create react app 创建的项目不在本文讨论范围
Step 1 - 初始化一个 Node 项目
- 创建项目目录
mkdir my-typescript-project
- 进入项目目录
cd my-typescript-project
- 项目初始化
yarn init -y
Step 2 - 安装依赖
yarn add typescript eslint ts-node nodemon @types/node -D
Step 3 - 配置 Typescript
- 在命令行执行如下命令创建 tsconfig.json 文件
yarn tsc --init
- 调整 tsconfig.json 文件的内容
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
"target": "ES2015"