Windows 检出 symlink 变文本:app/enterprise typecheck 报 TS1128,pre-push hook 拦住所有 push
Author: weifdingCreated Sep 27, 2026Updated Sep 27, 2026
现象
Windows 上 fresh clone 后,bun typecheck(根目录 turbo,12 个包)必失败,husky pre-push hook 因此拦截所有 push,Windows 贡献者只能 --no-verify 绕过——等于绕开了上游的质量门禁。
@mimo-ai/app:typecheck: $ tsgo -b
src/custom-elements.d.ts(1,1): error TS1128: Declaration or statement expected.
src/custom-elements.d.ts(1,2): error TS1128: Declaration or statement expected.
@mimo-ai/enterprise:typecheck: $ tsgo --noEmit
src/custom-elements.d.ts(1,1): error TS1128: Declaration or statement expected.
error: script "typecheck" exited with code 1
husky - pre-push script failed (code 1)
error: failed to push some refs根因
两个文件在仓库里是 symlink(git mode 120000):
packages/app/src/custom-elements.d.ts→../../ui/src/custom-elements.d.tspackages/enterprise/src/custom-elements.d.ts→../../ui/src/custom-elements.d.ts
Windows 默认 core.symlinks=false(需要管理员/开发者模式才能开),此时 git 检出 symlink 不创建链接,而是把 blob 内容原样写成文本文件——文件内容就变成了链接目标路径这一串字符:
$ cat packages/enterprise/src/custom-elements.d.ts
../../ui/src/custom-elements.d.tstsgo 把 ../../... 当 TypeScript 解析,第一行第一列就 TS1128。
$ git ls-files --stage packages/enterprise/src/custom-elements.d.ts
120000 e4ea0d6cebdad58ea12fc08dd7a3f732cdb45f8f 0 packages/enterprise/src/custom-elements.d.ts
$ git config core.symlinks
false其余 symlink(favicon png/svg、CLAUDE.md、sdks/vscode/images 等)不影响 typecheck,但同样会变成文本占位,按路径引用它们的构建同样会受影响。
环境
- OS: Windows 10 (10.0.19045) / Git Bash
- git: 默认
core.symlinks=false(fresh clone,未改配置) - bun: 1.3.14(
packageManager锁定版本) - 源码:
main@ 454521a8 - MiMoCode 版本: v0.1.15(issue #2553 同一环境)
复现步骤
- Windows 上
git clone https://github.com/XiaomiMiMo/MiMo-Code bun cibun typecheck→ app/enterprise 两包TS1128失败- 任意 commit 后
git push→ pre-push hook 跑同一 typecheck → push 被拦
本地临时解法(验证有效,未提交)
把两个文件改写为等价的 triple-slash 引用,全平台通用、不依赖 symlink:
/// <reference path="../../ui/src/custom-elements.d.ts" />改后根目录 bun typecheck 12/12 全过(含 app、enterprise)。这也是 #2554 能通过 pre-push 的原因(改动仅留在本地工作区,未入提交)。
建议的修复方向
给维护者的选择(不互斥):
- 仓库侧最干净:把这两个 symlink 替换为真实文件、内容为上面的 triple-slash reference——Windows 零配置,Linux/macOS 行为不变,顺带消除
core.symlinks状态导致的跨平台检出差异。 - 文档侧:在 CONTRIBUTING / README 的 Windows 开发章节注明需要开启 Windows 开发者模式(或
git config core.symlinks true后重新 checkout),并列出该失败的典型报错(TS1128)便于检索。 .gitattributes帮不上这个场景——它没有把 symlink 转成文本引用的属性,只能控制 eol/filter 等;真正要动的是文件形态(方案 1)或检出配置(方案 2)。
关联
- PR #2554 的
pre-push验证过程中踩到本问题 - 症状与 #2553 环境相同(Windows 10 + git bash),但两者是独立问题
Source: XiaomiMiMo/MiMo-Code