Commit 0221ac9
fix(types): PageData 干掉顶层 any index signature 让 build lint 过
PR #323 build 挂在 lint:app/types/doc.ts 两处 [key: string]: any
触发 @typescript-eslint/no-explicit-any error。
修法权衡
- frontmatter 嵌套对象:any → unknown(真的动态字段,调用方需显式 narrow)
- PageData 顶层:直接干掉 [key: string]: any 索引签名
为什么不是 unknown:试过 unknown,所有 5 处 `as PageData` cast 都炸
TS2352 "neither type sufficiently overlaps" —— Fumadocs 的 page.data
由 zod DocOut 推出,本身没有 index signature;PageData 顶层挂一个就跟
zod 类型形成"对方有但我没有"的不兼容。要么所有 cast 改 `as unknown as PageData`
(等于把 escape hatch 散到 5 处),要么干脆不挂顶层 index signature
(escape hatch 收窄到一处 frontmatter 子对象)。后者更干净。
调用方(page.tsx / sitemap.ts / search-index.ts)的现有访问字段
(docId / lang / draft / hidden / DateLike 候选)都已经在 PageData 顶层
显式声明,去掉 index signature 不影响任何现有代码,tsc + lint 均过。
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent e17d2b8 commit 0221ac9
1 file changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
46 | 46 | | |
0 commit comments