Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tsconfig paths has type error if out of cwd #715

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

PeachScript
Copy link
Member

修复超出 cwd 的 tsconfig paths 会出现模块找不到的类型错误的问题。

背景是 father 会在 d.ts 生成的时候自动替换 cwd 内的 paths 为相对路径,确保 d.ts 产物中的路径是可以被 resolve 的;但同时又会保留 cwd 之外的 paths,因为 monorepo 场景下会引用其他的子包,不能用相对路径去 resolve。

问题原因是之前 father 排除 cwd 之外的方式是把 tsconfig 中的部分 paths 删掉后再给 ts compiler,最后由 ts 插件来转换,但这其实会引起 paths 对应模块找不到的错误,而之前没报错是因为 4.3.2 之前有很多错误没抛出,ref: #701

解决方案是 father 保留原始的 tsconfig paths 给 ts compiler 确保编译过程中的类型完整,但对 ts 插件消费的 paths 做特殊处理,排除掉 cwd 之外的 paths。

@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02% 🎉

Comparison is base (b8a7a79) 94.39% compared to head (72a1907) 94.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #715      +/-   ##
==========================================
+ Coverage   94.39%   94.41%   +0.02%     
==========================================
  Files          55       55              
  Lines        1551     1559       +8     
  Branches      369      371       +2     
==========================================
+ Hits         1464     1472       +8     
+ Misses         87       82       -5     
- Partials        0        5       +5     
Files Changed Coverage Δ
src/builder/bundless/dts/index.ts 98.76% <100.00%> (+0.13%) ⬆️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@PeachScript PeachScript merged commit e566089 into master Sep 19, 2023
9 checks passed
@delete-merged-branch delete-merged-branch bot deleted the hotfix/outer-paths-type-error branch September 19, 2023 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant