umijs / father

NPM package development tool
MIT License
2.12k stars 273 forks source link

bug: 使用 Zod 时声明文件没有根据依赖及时生成 #733

Open ninesunsabiu opened 9 months ago

ninesunsabiu commented 9 months ago

Version

4.3.7

OS Version

macOS 14.1.1 (23B81)

Node.js Version

v18.12.1

Link to minimal reproduction

https://github.com/ninesunsabiu/father-with-zod

Steps to reproduce

  1. clone the minimal reproduction
  2. install the dependency
  3. run "dev"
  4. change the A.ts
diff --git a/src/A.ts b/src/A.ts
index d08b85e..5345cd5 100644
--- a/src/A.ts
+++ b/src/A.ts
@@ -2,7 +2,7 @@ import * as Z from "zod"

 export const schemaEntity = Z.lazy(() => {
     return Z.object({
-        id: Z.number(),
+        id: Z.string(),
         name: Z.string(),
     })
 })

What is expected?

A.d.tsB.d.ts 都可以得到正确的更新

What is actually happening?

只有 A.d.ts 按照 A.ts 进行了重新的生成,但是 B.d.ts 没有任何的更新 造成了不正确

Any additional comments? (optional)

使用了 tsc --watch 进行了对比, tsc 的 watch 是能根据 B => A 的关系,也把 B.d.ts 进行更新的

image
PeachScript commented 9 months ago

father 的 bundless 不会记录模块间的关系,看来 d.ts 的 watch 还是得交给 ts program 来做

ninesunsabiu commented 9 months ago

我浏览了 dts 的代码 是否因为 这里的输出 output 被限制成了只跟输入 inputFiles 有关

https://github.com/umijs/father/blob/b1b2ec3160029b63950f112bb1ad8e4b3e31203d/src/builder/bundless/dts/index.ts#L146-L158

https://github.com/umijs/father/blob/b1b2ec3160029b63950f112bb1ad8e4b3e31203d/src/builder/bundless/dts/index.ts#L175-L181

所以其实 ts program 有正确的得出 A.d.tsB.d.ts (没有运行调试过不太确定) 注释中指向了一个 https://github.com/umijs/father-next/issues/43 ,如果放开对于 inputFiles 的限制,会不会对它有影响?