Windows 检出 symlink 变文本:app/enterprise typecheck 报 TS1128,pre-push hook 拦住所有 push

Open Beginner friendly
#2,555 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
Half a day
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bun, git, typescript

Research direction

Start by inspecting the symlink entries for packages/app/src/custom-elements.d.ts and packages/enterprise/src/custom-elements.d.ts, then compare them with the shared declaration file under packages/ui/src. Verify the proposed cross-platform reference from a fresh Windows checkout and run bun typecheck; the work is done when both packages pass without requiring core.symlinks=true or --no-verify.

Written by the indexing model from the issue text.

Description

现象

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.ts
  • packages/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.ts

tsgo 把 ../../... 当 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 同一环境)

复现步骤

  1. Windows 上 git clone https://github.com/XiaomiMiMo/MiMo-Code
  2. bun ci
  3. bun typecheck → app/enterprise 两包 TS1128 失败
  4. 任意 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 的原因(改动仅留在本地工作区,未入提交)。

建议的修复方向

给维护者的选择(不互斥):

  1. 仓库侧最干净:把这两个 symlink 替换为真实文件、内容为上面的 triple-slash reference——Windows 零配置,Linux/macOS 行为不变,顺带消除 core.symlinks 状态导致的跨平台检出差异。
  2. 文档侧:在 CONTRIBUTING / README 的 Windows 开发章节注明需要开启 Windows 开发者模式(或 git config core.symlinks true 后重新 checkout),并列出该失败的典型报错(TS1128)便于检索。
  3. .gitattributes 帮不上这个场景——它没有把 symlink 转成文本引用的属性,只能控制 eol/filter 等;真正要动的是文件形态(方案 1)或检出配置(方案 2)。

关联

  • PR #2554 的 pre-push 验证过程中踩到本问题
  • 症状与 #2553 环境相同(Windows 10 + git bash),但两者是独立问题
Dominant language
TypeScript
Stars
13.7k
Forks
1.5k
Avg merge
7h 53m
Merged PRs (30d)
51

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from XiaomiMiMo/MiMo-Code

All issues in XiaomiMiMo/MiMo-Code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.