SuperAPI AI 工具集

type-check-baselines

编程与开发

查看项目

更新于 10-16 07:27

技能介绍

用途:RedisInsight 通过单向棘轮机制按项目限制 TypeScript 错误。当前错误数记录在各项目的 .tscheck.rec.json 中,CI 在任一(文件×错误码)计数增加时失败,计数只能下降。

主要能力与项目:UI 使用 redisinsight/ui/tsconfig.json 与 redisinsight/ui/.tscheck.rec.json,命令为 npm run type-check --prefix redisinsight/ui;API 使用 redisinsight/api/tsconfig.check.json(strict、extends base)与 redisinsight/api/.tscheck.rec.json,命令为 npm run type-check --prefix redisinsight/api;Desktop 使用 redisinsight/desktop/tsconfig.json 与 redisinsight/desktop/.tscheck.rec.json,命令为 npm run type-check --prefix redisinsight/desktop;configs/tsconfig.json 无基线文件,必须保持 0 错误,命令为 npx tsc --project configs/tsconfig.json --noEmit。

使用方式:在仓库根目录运行 npm run type-check 对比全部四个项目(E2E Playwright 由单独工作流检查,不在此列);修复错误后用 npm run tscheck 刷新 ui/api/desktop 基线,计数未变化的项目不产生 diff;npm run tscheck:force 强制覆盖基线,仅限紧急情况。刷新命令应始终通过根目录的 npm run tscheck / npm run tscheck:force 包装器执行,因为子目录脚本依赖仅安装在根 node_modules/.bin/ 下的工具;若必须直接调用,需手动前置根 bin 目录:PATH="$PWD/node_modules/.bin:$PATH" npm run tscheck --prefix redisinsight/ui。

API 使用专用 check tsconfig:redisinsight/api/tsconfig.check.json 继承基础 tsconfig.json 并添加 "strict": true、"strictPropertyInitialization": false、"useUnknownInCatchVariables": false、"noEmit": true;基础 tsconfig.json 保持不变以免影响 nest build,切勿在基础配置中启用 strict。

限制与处理:CI 报告“more TS errors than previously recorded”说明引入了新错误,应修复而非用 tscheck:force 掩盖;报告“baseline is outdated”说明已修复错误,从根目录运行 npm run tscheck 刷新并提交 .tscheck.rec.json。新增含 TS 错误的文件同样按新错误处理。首次建立基线仅需一次,使用 npm run tscheck:force --prefix redisinsight/<workspace>。在 redisinsight/api/ 执行 npm install 后 api postinstall 会重新生成 api-client,可能改变 UI 与 Desktop 计数,需相应刷新。本地 UI 与 CI 不一致时,通常是插件依赖未安装,先运行 npm run build:statics。本地 Desktop 与 CI 不一致时,需先构建 api(npm run build --prefix redisinsight/api,而非 build:prod)。审查 PR 时,拒绝无对应修复就上调计数、使用 tscheck:force、或在基础配置启用 strict 的改动;批准计数不变或下降并已提交基线更新的改动。