Repository navigation
Commit 7805d2b
probe
fix(webui): 让 webui 的类型检查与仓库其余部分用同一套标准
`typecheck:webui` 的 `typecheck:client` 报 6 个错、`typecheck:test` 报 389 个,
从 2026-09-21 `3b8f299` 加上这两个门起就一直是红的。
## 那 389 个错不在 webui,也不在第三方
它们在 `third_party/**`,而 webui 自己的代码是 0 错。看起来像第三方代码有
389 个问题,其实不是:`tsconfig.node.json` 打开了
`noUncheckedIndexedAccess` / `noImplicitOverride`,但**所有真正拥有那些代码的
项目都关着** —— `tsconfig.standalone.json`、`pi-mono/tsconfig.base.json`、
`sandbox-runtime/tsconfig.json` 一致关着。根 `pnpm typecheck` 读的是
standalone,所以一直是绿的。
webui `extends` 了 `tsconfig.node.json` 然后只继承、不覆盖,于是同一份代码在
一个门里干净、在另一个门里 389 个错。同一份代码、同一个检查器、两个结果。
TypeScript 没有按目录设选项的能力,所以这个全程序的值必须和**它自己输入的代码
实际使用的标准**一致。这是把 webui 摆正,不是给谁放水。
## 配套:路径表由生成器产出,不是手抄
`packages/webui/tsconfig.json` 现在继承 `tsconfig.paths.json` —— 由
`scripts/gen-tsconfig-paths.mjs` 生成。生成器同时产出仓库的两张路径表,
`check:tsconfig` 同时校验两张。
手抄 128 条有两个问题:`package-exports.mjs` 的存在意义就是让「类型检查的
路径表」和「测试解析器」不可能不一致;而根 `typecheck` 在 platform profile 里
是 `fullOnly`(跳过),手抄的表**没有任何门守护**。`tsconfig.standalone.json`
在本 PR 里逐字节未变。
## Gate A:6 个类型错
`workspace-progress.ts` 的 5 个 `TS2345` 是同一个病:事件类型被读成
`string | undefined`,再传给要求字面量联合的形参。用类型谓词收窄,因为
`if (type && ...)` 只能把 `undefined` 去掉,剩下的 `string` 仍然赋不进去。
第 6 个 `TS2488` 是联合类型的另一支让 `toolCalls` 成了 `unknown`,
`?? []` 之后仍不可迭代,用和下面那行同样的 `Array.isArray` 守卫解决。
没有用断言:这几处都是真的可选,不是「这里不可能 undefined」。
## 验证
| 门 | 之前 | 之后 |
|---|---|---|
| `typecheck:server` | ✅ | ✅ |
| `typecheck:client` | ❌ 6 | ✅ 0 |
| `typecheck:test` | ❌ 389 | ✅ 0 |
| 根 `pnpm typecheck` | ✅ | ✅ 未变 |
| `check:tsconfig` / `check:source` | ✅ | ✅ |
| `tsconfig.standalone.json` | — | 逐字节未变 |
`pnpm test`(webui)872/933 与基线一致 —— 本 PR 不含那 4 条基线红测的修复,
那是另一条 PR 的事。两个 PR 都合,`pnpm verify --profile platform` 才全绿。
`pnpm verify --profile platform` 整体在本 PR 提交前跑不完:gate 3
`export source preview` 要求工作树已提交。`test:capabilities` 1 个、
`test:sandbox` 2 个失败,均已 stash 后在干净基线上复现,是 macOS `/var` 与
`/private/var` 的环境差异,与本 PR 无关。1 parent 83321d0 commit 7805d2b
6 files changed
Lines changed: 504 additions & 28 deletions
File tree
- packages/webui
- src/client/projection
- release
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
218 | 232 | | |
219 | 233 | | |
220 | 234 | | |
| |||
231 | 245 | | |
232 | 246 | | |
233 | 247 | | |
234 | | - | |
| 248 | + | |
235 | 249 | | |
236 | 250 | | |
237 | 251 | | |
238 | | - | |
| 252 | + | |
239 | 253 | | |
240 | 254 | | |
241 | 255 | | |
| |||
245 | 259 | | |
246 | 260 | | |
247 | 261 | | |
248 | | - | |
| 262 | + | |
249 | 263 | | |
250 | 264 | | |
251 | 265 | | |
| |||
262 | 276 | | |
263 | 277 | | |
264 | 278 | | |
265 | | - | |
| 279 | + | |
266 | 280 | | |
267 | 281 | | |
268 | 282 | | |
| |||
329 | 343 | | |
330 | 344 | | |
331 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
332 | 350 | | |
333 | | - | |
| 351 | + | |
334 | 352 | | |
335 | 353 | | |
336 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
6 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
7 | 31 | | |
8 | 32 | | |
0 commit comments