ant-design-pro icon indicating copy to clipboard operation
ant-design-pro copied to clipboard

🐛 [BUG] 打包出的index.d.ts的文件路径问题

Open DH2221778997 opened this issue 9 months ago • 3 comments

🐛 bug 描述

Image 打包路径造成ts类型提示没了。上面是错的那种。下面是正常的。这是什么问题导致的。node_modules里的

Image Image Image

📷 复现步骤 | Recurrence steps

🏞 期望结果 | Expected results

💻 复现代码 | Recurrence code

© 版本信息

  • Ant Design Pro 版本: [e.g. 4.0.0]
  • umi 版本
  • 浏览器环境
  • 开发环境 [e.g. mac OS]

🚑 其他信息

DH2221778997 avatar Jul 10 '25 12:07 DH2221778997

当前 Issue 未检测到标题,请规范填写,谢谢!

The title of the current issue is not detected, please fill in according to the specifications, thank you!

github-actions[bot] avatar Jul 10 '25 12:07 github-actions[bot]

@dosu

afc163 avatar Jul 14 '25 05:07 afc163

你遇到的类型提示丢失问题,很可能是因为打包生成的 index.d.ts 路径或内容不正确,导致 VSCode/TypeScript 无法正确解析类型。pro-form 的打包配置是用 father + tsconfig,理论上会把类型文件输出到 es/index.d.ts,并且 package.json 的 types 字段也指向这里。如果类型提示丢失,常见原因有:

  1. 实际 node_modules 里的 es/index.d.ts 没有生成或内容不完整。
  2. 类型文件里 import/export 路径被打包工具或 tsconfig 路径别名处理错了,导致类型引用不到。
  3. 依赖包的类型没被正确发布或被 tree-shaking/sideEffects 配置影响。
  4. 你的项目 tsconfig 路径解析和 pro-form 的类型导出不兼容。

建议你:

  • 对比“正常”和“异常”情况下 node_modules/@ant-design/pro-form/es/index.d.ts 的内容和路径,看是否有 import 路径、类型 re-export 或内容缺失的区别。
  • 确认 package.json 的 types 字段是否正确指向 es/index.d.ts。
  • 清理 node_modules 和 lock 文件后重新安装依赖并重新 build。
  • 检查你的 tsconfig 路径配置,确保没有和 pro-form 类型导出冲突的地方。

如果可以,建议你把“正常”和“异常”情况下的 index.d.ts 文件内容贴出来,这样可以更精确定位问题。

目前 pro-form 的打包和类型导出流程没有特殊的自定义处理,都是标准 father + tsc 行为,相关配置可以参考这里这里。如果类型提示丢失,通常是类型文件本身内容或路径有问题,或者依赖包的类型没被正确发布。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

dosubot[bot] avatar Jul 14 '25 05:07 dosubot[bot]