-
Notifications
You must be signed in to change notification settings - Fork 149
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: hooks missing return type #1200
Conversation
🦋 Changeset detectedLatest commit: f20ab4d The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1200 +/- ##
=======================================
Coverage 99.99% 99.99%
=======================================
Files 851 851
Lines 18149 18149
Branches 1582 1582
=======================================
Hits 18148 18148
Misses 1 1 ☔ View full report in Codecov by Sentry. |
import useProvider from './useProvider'; | ||
|
||
export default function useAccount() { | ||
const { account } = useProvider(); | ||
const { account } = useProvider() as UniversalWeb3ProviderInterface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不有应该啊,总感觉有其它更好的办法,as 一般是用在那种本来就有可能有多种类型的情况下用来指定类型。但是这个的问题是类型没有推理出来,最好再研究一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
又改了一下,原因似乎是由于把 enum 和 type/interface 放到同一个文件里面了。导致后面的模块寻找类型的时候出错了。
我在本地试了下可以了,你那边最好也拉下来试一下。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥 enum 和 type 放一起会有问题?可以研究下两种情况下构建出来的 type 文件有什么区别。
感觉这种问题一般是 ts 构建 .d.ts 文件的时候把一些类型吞掉了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
检查了下,编译出来的类型并没有丢失。
而且毕竟,这个文件中的类型很多地方都有用,如果丢失了,那么其他用到的地方应该都有问题,而事实是只发现这两个 hook 里面的类型有问题。
能想到的其他原因,例如“循环依赖”、“TS 编译时类型查找错误”,似乎都不能满足上面这一点。。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
奇怪,那为啥分开写到一个单独的文件就好了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种修复方式似乎是不对的,我今天再次执行 build 后,又出现了原问题。
@@ -1,3 +1,4 @@ | |||
export * from './enums'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉 enums 算是 types 中的一种,应该在 types 中导出 enums。
fix #1175
💡 Background and solution
修复
useAccount
和useConnection
返回类型丢失问题🔗 Related issue link