tweak: add *.tsbuildinfo to .gitignore to prevent stale incremental cache

This commit is contained in:
2026-07-02 17:34:36 +08:00
parent a4ca6b2ef9
commit 2010751684
5 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
## Context
TypeScript 的 `incremental: true` 选项会在编译时生成 `.tsbuildinfo` 文件用于增量编译加速。当 `dist/` 目录被清理(如 `nest build``deleteOutDir: true` 行为)但 `.tsbuildinfo` 缓存未被同步清理时TypeScript 会基于缓存判定所有文件已是最新、跳过编译,导致运行时找不到输出文件。
## Goals / Non-Goals
**Goals:**
-`*.tsbuildinfo` 加入 `.gitignore`,防止缓存文件被版本控制追踪
**Non-Goals:**
- 不改变 TypeScript 编译配置
- 不添加自动清理缓存的构建脚本
## Decisions
- **方案**:在 `.gitignore` 中新增一行 `*.tsbuildinfo` 规则,置于「构建产物」区域下方
- **理由**:这是最小改动方案。`.tsbuildinfo` 属于构建产物类文件,应与 `dist/``build/` 等同对待;加入 `.gitignore` 后既不会被提交,也提示开发者此为自动生成文件
## Risks / Trade-offs
- 无风险。该改动仅影响 git 追踪行为,不改变编译或运行逻辑