mini-typescript 项目教程

mini-typescript 项目教程

mini-typescriptA miniature model of the Typescript compiler, intended to teach the structure of the real Typescript compiler项目地址:https://gitcode.com/gh_mirrors/mi/mini-typescript

1. 项目的目录结构及介绍

mini-typescript 是一个用于教学目的的 TypeScript 编译器模型。以下是其目录结构的详细介绍:

mini-typescript/
├── baselines/
│   └── reference/
├── src/
│   ├── checker/
│   ├── compiler/
│   ├── parser/
│   ├── program/
│   ├── scanner/
│   ├── transformer/
│   └── types.ts
├── tests/
│   └── singleVar.ts
├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── package-lock.json
├── package.json
└── tsconfig.json
  • baselines/: 包含参考基准文件。
  • src/: 包含编译器的主要源代码文件。
    • checker/: 类型检查器代码。
    • compiler/: 编译器核心代码。
    • parser/: 解析器代码。
    • program/: 程序管理代码。
    • scanner/: 扫描器代码。
    • transformer/: 转换器代码。
    • types.ts: 类型定义文件。
  • tests/: 包含测试文件。
  • .gitattributes: Git 属性配置文件。
  • .gitignore: Git 忽略配置文件。
  • LICENSE: 项目许可证。
  • README.md: 项目说明文档。
  • package-lock.json: npm 依赖锁定文件。
  • package.json: npm 项目配置文件。
  • tsconfig.json: TypeScript 配置文件。

2. 项目的启动文件介绍

项目的启动文件是 src/compiler/index.ts。这个文件是编译器的入口点,负责初始化和调用编译器的各个模块。

3. 项目的配置文件介绍

package.json

package.json 文件包含了项目的元数据和依赖信息。以下是一些关键字段:

{
  "name": "mini-typescript",
  "version": "1.0.0",
  "description": "A miniature model of the Typescript compiler intended to teach the structure of the real Typescript compiler",
  "main": "src/compiler/index.ts",
  "scripts": {
    "build": "tsc",
    "watch": "tsc --watch",
    "mtsc": "node dist/compiler/index.js"
  },
  "dependencies": {
    "typescript": "^4.0.0"
  }
}
  • name: 项目名称。
  • version: 项目版本。
  • description: 项目描述。
  • main: 项目入口文件。
  • scripts: 包含可执行的脚本命令。
  • dependencies: 项目依赖。

tsconfig.json

tsconfig.json 文件包含了 TypeScript 编译器的配置选项。以下是一些关键字段:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "outDir": "./dist",
    "strict": true,
    "esModuleInterop": true
  },
  "include": [
    "src/**/*"
  ]
}
  • compilerOptions: 编译器选项。
    • target: 编译目标版本。
    • module: 模块系统。
    • outDir: 输出目录。
    • strict: 启用严格模式。
    • esModuleInterop: 启用 ES 模块互操作。
  • include: 包含的文件和目录。

mini-typescriptA miniature model of the Typescript compiler, intended to teach the structure of the real Typescript compiler项目地址:https://gitcode.com/gh_mirrors/mi/mini-typescript

  • 18
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

劳颜甜Hattie

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值